[3.13] gh-122170: Handle ValueError raised by os.stat() in linecache (GH-122176) (GH-122348)

(cherry picked from commit 7a6d4ccf0e)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2024-07-27 12:54:49 +02:00 committed by GitHub
parent 40925103fc
commit 3648a945e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 37 additions and 2 deletions

View file

@ -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()