Backporting to 3.8 and adding a NEWS item (I should have added one to the master branch -- oh well).
(cherry picked from commit
b86636bff4b29ce23c886df079715dd951f13a07)
Co-authored-by: Andrew Kuchling <amk@amk.ca>
try:
stat = os.stat(fullname)
except OSError:
- del cache[filename]
+ cache.pop(filename, None)
continue
if size != stat.st_size or mtime != stat.st_mtime:
- del cache[filename]
+ cache.pop(filename, None)
def updatecache(filename, module_globals=None):
if filename in cache:
if len(cache[filename]) != 1:
- del cache[filename]
+ cache.pop(filename, None)
if not filename or (filename.startswith('<') and filename.endswith('>')):
return []
--- /dev/null
+:mod:`linecache` could crash with a :exc:`KeyError` when accessed from multiple threads.
+Fix by Michael Graczyk.