summaryrefslogtreecommitdiff
path: root/django/utils/module_loading.py
diff options
context:
space:
mode:
authorThomas Khyn <thomas@ksytek.com>2017-06-09 06:34:20 +1200
committerTim Graham <timograham@gmail.com>2017-06-08 14:34:20 -0400
commitf6bd00131e687aedf2719ad31e84b097562ca5f2 (patch)
tree912e24529a916e40f2e166132625c5a9d48448db /django/utils/module_loading.py
parentaf69f14e7ba06bb7dee257ec02b885f4828c77ff (diff)
downloaddjango-f6bd00131e687aedf2719ad31e84b097562ca5f2.tar.gz
Fixed #28241 -- Allowed module_has_submodule()'s module_name arg to be a dotted path.
Diffstat (limited to 'django/utils/module_loading.py')
-rw-r--r--django/utils/module_loading.py9
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):