diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-04-01 13:54:05 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-04-01 13:54:05 (GMT) |
commit | c512adc90d49b1dae3ae14c81826e03c9ea46ba5 (patch) | |
tree | 0707548efd8968ee36a3ccd5e52ad54780c420ff /Lib/linecache.py | |
parent | 263dcd20a374d540c8f0bc07332f1657adf6da83 (diff) | |
download | cpython-c512adc90d49b1dae3ae14c81826e03c9ea46ba5.zip cpython-c512adc90d49b1dae3ae14c81826e03c9ea46ba5.tar.gz cpython-c512adc90d49b1dae3ae14c81826e03c9ea46ba5.tar.bz2 |
Issue #23838: linecache now clears the cache and returns an empty result on
MemoryError.
Diffstat (limited to 'Lib/linecache.py')
-rw-r--r-- | Lib/linecache.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/linecache.py b/Lib/linecache.py index e505b03..884cbf4 100644 --- a/Lib/linecache.py +++ b/Lib/linecache.py @@ -37,8 +37,12 @@ def getlines(filename, module_globals=None): if filename in cache: return cache[filename][2] - else: + + try: return updatecache(filename, module_globals) + except MemoryError: + clearcache() + return [] def checkcache(filename=None): |