summaryrefslogtreecommitdiffstats
path: root/Lib/runpy.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/runpy.py')
-rwxr-xr-xLib/runpy.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/Lib/runpy.py b/Lib/runpy.py
index 5038266..22a2989 100755
--- a/Lib/runpy.py
+++ b/Lib/runpy.py
@@ -65,13 +65,14 @@ def _run_module_code(code, init_globals=None,
# This helper is needed due to a missing component in the PEP 302
# loader protocol (specifically, "get_filename" is non-standard)
+# Since we can't introduce new features in maintenance releases,
+# support was added to zipimporter under the name '_get_filename'
def _get_filename(loader, mod_name):
- try:
- get_filename = loader.get_filename
- except AttributeError:
- return None
- else:
- return get_filename(mod_name)
+ for attr in ("get_filename", "_get_filename"):
+ meth = getattr(loader, attr, None)
+ if meth is not None:
+ return meth(mod_name)
+ return None
# Helper to get the loader, code and filename for a module
def _get_module_details(mod_name):