mirror of
https://github.com/python/cpython.git
synced 2025-07-29 14:15:07 +00:00
Fix several issues relating to access to source code inside zipfiles. Initial work by Alexander Belopolsky. See Misc/NEWS in this checkin for details.
This commit is contained in:
parent
3e16f3dd7f
commit
a2053475bb
10 changed files with 161 additions and 48 deletions
|
@ -88,21 +88,20 @@ def updatecache(filename, module_globals=None):
|
|||
get_source = getattr(loader, 'get_source', None)
|
||||
|
||||
if name and get_source:
|
||||
if basename.startswith(name.split('.')[-1]+'.'):
|
||||
try:
|
||||
data = get_source(name)
|
||||
except (ImportError, IOError):
|
||||
pass
|
||||
else:
|
||||
if data is None:
|
||||
# No luck, the PEP302 loader cannot find the source
|
||||
# for this module.
|
||||
return []
|
||||
cache[filename] = (
|
||||
len(data), None,
|
||||
[line+'\n' for line in data.splitlines()], fullname
|
||||
)
|
||||
return cache[filename][2]
|
||||
try:
|
||||
data = get_source(name)
|
||||
except (ImportError, IOError):
|
||||
pass
|
||||
else:
|
||||
if data is None:
|
||||
# No luck, the PEP302 loader cannot find the source
|
||||
# for this module.
|
||||
return []
|
||||
cache[filename] = (
|
||||
len(data), None,
|
||||
[line+'\n' for line in data.splitlines()], fullname
|
||||
)
|
||||
return cache[filename][2]
|
||||
|
||||
# Try looking through the module search path.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue