linecache.updatecache(): don't the lines into the cache on IOError

Use the same behaviour than Python 2.7.
This commit is contained in:
Victor Stinner 2010-09-29 01:30:45 +00:00
parent 78f43a73cb
commit 41a64a53a3
1 changed files with 1 additions and 1 deletions

View File

@ -128,7 +128,7 @@ def updatecache(filename, module_globals=None):
with open(fullname, 'r', encoding=coding) as fp: with open(fullname, 'r', encoding=coding) as fp:
lines = fp.readlines() lines = fp.readlines()
except IOError: except IOError:
lines = [] return []
if lines and not lines[-1].endswith('\n'): if lines and not lines[-1].endswith('\n'):
lines[-1] += '\n' lines[-1] += '\n'
size, mtime = stat.st_size, stat.st_mtime size, mtime = stat.st_size, stat.st_mtime