diff options
Diffstat (limited to 'modutils.py')
-rw-r--r-- | modutils.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/modutils.py b/modutils.py index 66a7a4ac..efc999b4 100644 --- a/modutils.py +++ b/modutils.py @@ -552,7 +552,10 @@ def _module_file(modpath, path=None): except AttributeError: checkeggs = False # pkg_resources support (aka setuptools namespace packages) - if pkg_resources is not None and modpath[0] in pkg_resources._namespace_packages and len(modpath) > 1: + if (pkg_resources is not None + and modpath[0] in pkg_resources._namespace_packages + and modpath[0] in sys.modules + and len(modpath) > 1): # setuptools has added into sys.modules a module object with proper # __path__, get back information from there module = sys.modules[modpath.pop(0)] |