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

(cherry picked from commit 21cbdae90f)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2022-06-30 02:59:33 -07:00 committed by GitHub
parent c5ecfa0a1e
commit 20b8c9eee0
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'