Browse Source

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

Needs a test, which likely requires introducing a mock library.
pull/272/merge
Ron DuPlain 13 years ago
parent
commit
1f20a11284
  1. 9
      flask/helpers.py

9
flask/helpers.py

@ -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…
Cancel
Save