diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-04-01 16:56:13 +0300 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-04-01 16:56:13 +0300 |
commit | 05ddbf0875b449f69616c31fbbe49dd5f3d5e329 (patch) | |
tree | e7cbf07a3fad26c69006f38e2216d5c56d1c786b /Lib/linecache.py | |
parent | It wasn't a typo, it is the mnemonic (AT=@). (diff) | |
parent | Issue #23838: linecache now clears the cache and returns an empty result on (diff) | |
download | cpython-05ddbf0875b449f69616c31fbbe49dd5f3d5e329.tar.gz cpython-05ddbf0875b449f69616c31fbbe49dd5f3d5e329.tar.bz2 cpython-05ddbf0875b449f69616c31fbbe49dd5f3d5e329.zip |
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 | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Lib/linecache.py b/Lib/linecache.py index 6e65c37e135..3afcce1f0a1 100644 --- a/Lib/linecache.py +++ b/Lib/linecache.py @@ -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): |