Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d72ea60

Browse filesBrowse files
authored
issue-25872: Fix KeyError using linecache from multiple threads (GH-18007)
The crash that this fixes occurs when using traceback and other modules from multiple threads; del cache[filename] can raise a KeyError.
1 parent 97e1568 commit d72ea60
Copy full SHA for d72ea60

File tree

Expand file treeCollapse file tree

1 file changed

+3
-3
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-3
lines changed

‎Lib/linecache.py

Copy file name to clipboardExpand all lines: Lib/linecache.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ def checkcache(filename=None):
7171
try:
7272
stat = os.stat(fullname)
7373
except OSError:
74-
del cache[filename]
74+
cache.pop(filename, None)
7575
continue
7676
if size != stat.st_size or mtime != stat.st_mtime:
77-
del cache[filename]
77+
cache.pop(filename, None)
7878

7979

8080
def updatecache(filename, module_globals=None):
@@ -84,7 +84,7 @@ def updatecache(filename, module_globals=None):
8484

8585
if filename in cache:
8686
if len(cache[filename]) != 1:
87-
del cache[filename]
87+
cache.pop(filename, None)
8888
if not filename or (filename.startswith('<') and filename.endswith('>')):
8989
return []
9090

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.