Skip to content

Commit 852e8a7

Browse files
[3.8] bpo-25872: Fix KeyError in linecache when multithreaded (GH-18007) (GH-20092)
Backporting to 3.8 and adding a NEWS item (I should have added one to the master branch -- oh well). (cherry picked from commit b86636b) Co-authored-by: Andrew Kuchling <amk@amk.ca>
1 parent 5f977e0 commit 852e8a7

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Lib/linecache.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ def checkcache(filename=None):
7373
try:
7474
stat = os.stat(fullname)
7575
except OSError:
76-
del cache[filename]
76+
cache.pop(filename, None)
7777
continue
7878
if size != stat.st_size or mtime != stat.st_mtime:
79-
del cache[filename]
79+
cache.pop(filename, None)
8080

8181

8282
def updatecache(filename, module_globals=None):
@@ -86,7 +86,7 @@ def updatecache(filename, module_globals=None):
8686

8787
if filename in cache:
8888
if len(cache[filename]) != 1:
89-
del cache[filename]
89+
cache.pop(filename, None)
9090
if not filename or (filename.startswith('<') and filename.endswith('>')):
9191
return []
9292

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
:mod:`linecache` could crash with a :exc:`KeyError` when accessed from multiple threads.
2+
Fix by Michael Graczyk.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy