mirror of
https://github.com/python/cpython.git
synced 2025-08-09 19:38:42 +00:00
[3.12] gh-122170: Handle ValueError raised by os.stat() in linecache (GH-122176) (GH-122349)
(cherry picked from commit 7a6d4ccf0e
)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This commit is contained in:
parent
a4449a1ada
commit
2e37d67db2
3 changed files with 37 additions and 2 deletions
|
@ -70,7 +70,7 @@ def checkcache(filename=None):
|
|||
continue # no-op for files loaded via a __loader__
|
||||
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:
|
||||
|
@ -128,10 +128,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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue