diff options
author | Bénédikt Tran <10796600+picnixz@users.noreply.github.com> | 2024-07-27 10:10:42 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-27 10:10:42 (GMT) |
commit | 7a6d4ccf0ec16e09f0d8b21c5a0c591e5e3e45f7 (patch) | |
tree | baf9071ff91a599fabf2d8f0378bb91e13077671 /Lib/linecache.py | |
parent | 8ac5565be2e5a11fad643c2fe9cbf16d2ddb95cd (diff) | |
download | cpython-7a6d4ccf0ec16e09f0d8b21c5a0c591e5e3e45f7.zip cpython-7a6d4ccf0ec16e09f0d8b21c5a0c591e5e3e45f7.tar.gz cpython-7a6d4ccf0ec16e09f0d8b21c5a0c591e5e3e45f7.tar.bz2 |
gh-122170: Handle ValueError raised by os.stat() in linecache (GH-122176)
Diffstat (limited to 'Lib/linecache.py')
-rw-r--r-- | Lib/linecache.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/linecache.py b/Lib/linecache.py index 3462f1c..4b38a04 100644 --- a/Lib/linecache.py +++ b/Lib/linecache.py @@ -70,7 +70,7 @@ def checkcache(filename=None): return try: stat = os.stat(fullname) - except OSError: + except (OSError, ValueError): cache.pop(filename, None) continue if size != stat.st_size or mtime != stat.st_mtime: @@ -135,10 +135,12 @@ def updatecache(filename, module_globals=None): try: stat = os.stat(fullname) break - except OSError: + except (OSError, ValueError): pass else: return [] + except ValueError: # may be raised by os.stat() + return [] try: with tokenize.open(fullname) as fp: lines = fp.readlines() |