mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
[3.12] gh-126775: make linecache.checkcache threadsafe and GC re-entrency safe (GH-126776) (#127779)
gh-126775: make linecache.checkcache threadsafe and GC re-entrency safe (GH-126776)
(cherry picked from commit 2233c303e4)
Co-authored-by: Thomas Grainger <tagrain@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Bartosz Sławecki <bartoszpiotrslawecki@gmail.com>
This commit is contained in:
parent
fa935225a4
commit
e881dd1c46
2 changed files with 9 additions and 5 deletions
|
|
@ -54,14 +54,17 @@ def checkcache(filename=None):
|
|||
(This is not checked upon each call!)"""
|
||||
|
||||
if filename is None:
|
||||
filenames = list(cache.keys())
|
||||
elif filename in cache:
|
||||
filenames = [filename]
|
||||
# get keys atomically
|
||||
filenames = cache.copy().keys()
|
||||
else:
|
||||
return
|
||||
filenames = [filename]
|
||||
|
||||
for filename in filenames:
|
||||
entry = cache[filename]
|
||||
try:
|
||||
entry = cache[filename]
|
||||
except KeyError:
|
||||
continue
|
||||
|
||||
if len(entry) == 1:
|
||||
# lazy cache entry, leave it lazy.
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
Make :func:`linecache.checkcache` thread safe and GC re-entrancy safe.
|
||||
Loading…
Add table
Add a link
Reference in a new issue