Skip to content

Commit 9cd7e17

Browse files
committed
Fix python#29519: weakref spewing exceptions during interp finalization
1 parent e662445 commit 9cd7e17

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Lib/weakref.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ def __init__(*args, **kw):
106106
self, *args = args
107107
if len(args) > 1:
108108
raise TypeError('expected at most 1 arguments, got %d' % len(args))
109-
def remove(wr, selfref=ref(self)):
109+
def remove(wr, selfref=ref(self), _atomic_removal=_remove_dead_weakref):
110110
self = selfref()
111111
if self is not None:
112112
if self._iterating:
113113
self._pending_removals.append(wr.key)
114114
else:
115115
# Atomic removal is necessary since this function
116116
# can be called asynchronously by the GC
117-
_remove_dead_weakref(d, wr.key)
117+
_atomic_removal(d, wr.key)
118118
self._remove = remove
119119
# A list of keys to be removed
120120
self._pending_removals = []

Misc/NEWS

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ Extension Modules
2323
Library
2424
-------
2525

26+
- Issue #29519: Fix weakref spewing exceptions during interpreter shutdown
27+
when used with a rare combination of multiprocessing and custom codecs.
28+
2629
- Issue #29416: Prevent infinite loop in pathlib.Path.mkdir
2730

2831
- Issue #29444: Fixed out-of-bounds buffer access in the group() method of

0 commit comments

Comments
 (0)