mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Patch from Gordon McMillan.
updatecache(): When using imputil, sys.path may contain things other than strings. Ignore such things instead of blowing up. Hard to say whether this is a bugfix or a feature ...
This commit is contained in:
parent
4324aa3572
commit
12f21ae07f
1 changed files with 12 additions and 5 deletions
|
@ -69,15 +69,22 @@ def updatecache(filename):
|
||||||
try:
|
try:
|
||||||
stat = os.stat(fullname)
|
stat = os.stat(fullname)
|
||||||
except os.error, msg:
|
except os.error, msg:
|
||||||
# Try looking through the module search path
|
# Try looking through the module search path.
|
||||||
basename = os.path.split(filename)[1]
|
basename = os.path.split(filename)[1]
|
||||||
for dirname in sys.path:
|
for dirname in sys.path:
|
||||||
fullname = os.path.join(dirname, basename)
|
# When using imputil, sys.path may contain things other than
|
||||||
|
# strings; ignore them when it happens.
|
||||||
try:
|
try:
|
||||||
stat = os.stat(fullname)
|
fullname = os.path.join(dirname, basename)
|
||||||
break
|
except (TypeError, AttributeError):
|
||||||
except os.error:
|
# Not sufficiently string-like to do anything useful with.
|
||||||
pass
|
pass
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
stat = os.stat(fullname)
|
||||||
|
break
|
||||||
|
except os.error:
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
# No luck
|
# No luck
|
||||||
## print '*** Cannot stat', filename, ':', msg
|
## print '*** Cannot stat', filename, ':', msg
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue