gh-92336: linecache.getline should not raise exceptions on decoding errors (GH-94410)

This commit is contained in:
Irit Katriel 2022-06-30 10:18:18 +01:00 committed by GitHub
parent 68fb03249f
commit 21cbdae90f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 7 deletions

View file

@ -135,7 +135,7 @@ def updatecache(filename, module_globals=None):
try:
with tokenize.open(fullname) as fp:
lines = fp.readlines()
except OSError:
except (OSError, UnicodeDecodeError, SyntaxError):
return []
if lines and not lines[-1].endswith('\n'):
lines[-1] += '\n'