diff options
Diffstat (limited to 'django/utils/module_loading.py')
| -rw-r--r-- | django/utils/module_loading.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/django/utils/module_loading.py b/django/utils/module_loading.py index 26a7e51e0d..f8aadb34df 100644 --- a/django/utils/module_loading.py +++ b/django/utils/module_loading.py @@ -11,10 +11,16 @@ def module_has_submodule(package, module_name): return sys.modules[name] is not None except KeyError: pass + try: + package_path = package.__path__ # No __path__, then not a package. + except AttributeError: + # Since the remainder of this function assumes that we're dealing with + # a package (module with a __path__), so if it's not, then bail here. + return False for finder in sys.meta_path: - if finder.find_module(name, package.__path__): + if finder.find_module(name, package_path): return True - for entry in package.__path__: # No __path__, then not a package. + for entry in package_path: try: # Try the cached finder. finder = sys.path_importer_cache[entry] |
