Skip to content

Commit 3e37f4a

Browse files
methaneambv
authored andcommitted
bpo-29519: weakref spewing exceptions during interp finalization (#2958)
(cherry pick from 9cd7e17)
1 parent fa90179 commit 3e37f4a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Lib/weakref.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ def __init__(*args, **kw):
5353
args = args[1:]
5454
if len(args) > 1:
5555
raise TypeError('expected at most 1 arguments, got %d' % len(args))
56-
def remove(wr, selfref=ref(self)):
56+
def remove(wr, selfref=ref(self), _atomic_removal=_remove_dead_weakref):
5757
self = selfref()
5858
if self is not None:
5959
if self._iterating:
6060
self._pending_removals.append(wr.key)
6161
else:
6262
# Atomic removal is necessary since this function
6363
# can be called asynchronously by the GC
64-
_remove_dead_weakref(self.data, wr.key)
64+
_atomic_removal(self.data, wr.key)
6565
self._remove = remove
6666
# A list of keys to be removed
6767
self._pending_removals = []
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix weakref spewing exceptions during interpreter shutdown when used with a
2+
rare combination of multiprocessing and custom codecs.

0 commit comments

Comments
 (0)