Issue #23838: linecache now clears the cache and returns an empty result on

MemoryError.
This commit is contained in:
Serhiy Storchaka 2015-04-01 16:56:13 +03:00
commit 05ddbf0875
3 changed files with 25 additions and 7 deletions

View file

@ -40,11 +40,14 @@ def getlines(filename, module_globals=None):
if filename in cache:
entry = cache[filename]
if len(entry) == 1:
return updatecache(filename, module_globals)
return cache[filename][2]
else:
if len(entry) != 1:
return cache[filename][2]
try:
return updatecache(filename, module_globals)
except MemoryError:
clearcache()
return []
def checkcache(filename=None):