mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user