forked from orbit-oss/flask
Fall back to imports w/exotic pkg loaders, #380.
Needs a test, which likely requires introducing a mock library.
This commit is contained in:
parent
83189f20bf
commit
1f20a11284
1 changed files with 8 additions and 1 deletions
|
|
@ -526,10 +526,17 @@ def find_package(import_name):
|
|||
# For .egg, zipimporter does not have get_filename until Python 2.7.
|
||||
if hasattr(loader, 'get_filename'):
|
||||
filename = loader.get_filename(root_mod_name)
|
||||
else:
|
||||
elif hasattr(loader, 'archive'):
|
||||
# zipimporter's loader.archive points to the .egg or .zip
|
||||
# archive filename is dropped in call to dirname below.
|
||||
filename = loader.archive
|
||||
else:
|
||||
# At least one loader is missing both get_filename and archive:
|
||||
# Google App Engine's HardenedModulesHook
|
||||
#
|
||||
# Fall back to imports.
|
||||
__import__(import_name)
|
||||
filename = sys.modules[import_name].__file__
|
||||
package_path = os.path.abspath(os.path.dirname(filename))
|
||||
# package_path ends with __init__.py for a package
|
||||
if loader.is_package(root_mod_name):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue