diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2011-01-30 13:10:47 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2011-01-30 13:10:47 +0000 |
| commit | 56ebab9d8596f63db38053816ec961656e49ed38 (patch) | |
| tree | 651e01d1b8f3e80defbe3c4101de67b44f8fea1d /django/utils/module_loading.py | |
| parent | 4392c8e67ed6009602ff72af0a786c1053d55302 (diff) | |
Fixed #14698 -- Ensure that module_has_sumodule doesn't mistake a cache miss for an existent package. Thanks to Łukasz Rekucki for the report and patch, and to shields for the test case.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15362 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/utils/module_loading.py')
| -rw-r--r-- | django/utils/module_loading.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/django/utils/module_loading.py b/django/utils/module_loading.py index f251035387..32ca69a9fd 100644 --- a/django/utils/module_loading.py +++ b/django/utils/module_loading.py @@ -6,8 +6,11 @@ import sys def module_has_submodule(package, module_name): """See if 'module' is in 'package'.""" name = ".".join([package.__name__, module_name]) - if name in sys.modules: - return True + try: + # None indicates a cached miss; see mark_miss() in Python/import.c. + return sys.modules[name] is not None + except KeyError: + pass for finder in sys.meta_path: if finder.find_module(name): return True |
