diff options
| author | Nick Coghlan <ncoghlan@gmail.com> | 2008-12-14 11:30:16 (GMT) |
|---|---|---|
| committer | Nick Coghlan <ncoghlan@gmail.com> | 2008-12-14 11:30:16 (GMT) |
| commit | 30327242b3c83cfbedb21b5b869c52b855573221 (patch) | |
| tree | 98bcb76f83d984d0fb45fcabd3dbee4d6f06ba82 /Lib/runpy.py | |
| parent | d0a70d4bab2ba95ce1d6eae73f61f1e4cdf35941 (diff) | |
| download | cpython-30327242b3c83cfbedb21b5b869c52b855573221.zip cpython-30327242b3c83cfbedb21b5b869c52b855573221.tar.gz cpython-30327242b3c83cfbedb21b5b869c52b855573221.tar.bz2 | |
Merged revisions 67750-67751 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r67750 | nick.coghlan | 2008-12-14 20:54:50 +1000 (Sun, 14 Dec 2008) | 1 line
Fix several issues relating to access to source code inside zipfiles. Initial work by Alexander Belopolsky. See Misc/NEWS in this checkin for details.
........
r67751 | nick.coghlan | 2008-12-14 21:09:40 +1000 (Sun, 14 Dec 2008) | 1 line
Add file that was missed from r67750
........
Diffstat (limited to 'Lib/runpy.py')
| -rwxr-xr-x | Lib/runpy.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Lib/runpy.py b/Lib/runpy.py index f3c3890..fea6104 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): |
