diff options
Diffstat (limited to 'django/utils/module_loading.py')
-rw-r--r-- | django/utils/module_loading.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/django/utils/module_loading.py b/django/utils/module_loading.py index 5e5fa0e69e..413c6c2540 100644 --- a/django/utils/module_loading.py +++ b/django/utils/module_loading.py @@ -70,7 +70,14 @@ def module_has_submodule(package, module_name): return False full_module_name = package_name + '.' + module_name - return importlib_find(full_module_name, package_path) is not None + try: + return importlib_find(full_module_name, package_path) is not None + except (ImportError, AttributeError): + # When module_name is an invalid dotted path, Python raises ImportError + # (or ModuleNotFoundError in Python 3.6+). AttributeError may be raised + # if the penultimate part of the path is not a package. + # (http://bugs.python.org/issue30436) + return False def module_dir(module): |