Skip to content
Myr

Fall back to imports w/exotic pkg loaders, #380.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Needs a test, which likely requires introducing a mock library.

authored by Ron DuPlain · committed by Ron DuPlain · parent 83189f2 · Browse files · 1 file+8 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+8 added−1 removed

  • other:+8 added−1 removed

1 file+8 added−1 removed

modified:flask/helpers.py+8 added-1 removed
524 unmodified lines
525 else:526 # For .egg, zipimporter does not have get_filename until Python 2.7.527 if hasattr(loader, 'get_filename'):528 filename = loader.get_filename(root_mod_name)529 else:529 elif hasattr(loader, 'archive'):530 # zipimporter's loader.archive points to the .egg or .zip531 # archive filename is dropped in call to dirname below.532 filename = loader.archive533 else:534 # At least one loader is missing both get_filename and archive:535 # Google App Engine's HardenedModulesHook536 #537 # Fall back to imports.538 __import__(import_name)539 filename = sys.modules[import_name].__file__540 package_path = os.path.abspath(os.path.dirname(filename))541 # package_path ends with __init__.py for a package542 if loader.is_package(root_mod_name):543 package_path = os.path.dirname(package_path)
135 unmodified lines