File tree Expand file tree Collapse file tree 3 files changed +11
-0
lines changed Expand file tree Collapse file tree 3 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -1454,6 +1454,12 @@ def isatty(self):
14541454 pair = self .tp (SelectableIsAtty (True ), SelectableIsAtty (True ))
14551455 self .assertTrue (pair .isatty ())
14561456
1457+ def test_weakref_clearing (self ):
1458+ brw = self .tp (self .MockRawIO (), self .MockRawIO ())
1459+ ref = weakref .ref (brw )
1460+ brw = None
1461+ ref = None # Shouldn't segfault.
1462+
14571463class CBufferedRWPairTest (BufferedRWPairTest ):
14581464 tp = io .BufferedRWPair
14591465
Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ What's New in Python 3.2.6?
1010Library
1111-------
1212
13+ - Issue #22517: When a io.BufferedRWPair object is deallocated, clear its
14+ weakrefs.
15+
1316- Issue #16041: CVE-2013-1752: poplib: Limit maximum line lengths to 2048 to
1417 prevent readline() calls from consuming too much memory. Patch by Jyrki
1518 Pulliainen.
Original file line number Diff line number Diff line change @@ -2141,6 +2141,8 @@ static void
21412141bufferedrwpair_dealloc (rwpair * self )
21422142{
21432143 _PyObject_GC_UNTRACK (self );
2144+ if (self -> weakreflist != NULL )
2145+ PyObject_ClearWeakRefs ((PyObject * )self );
21442146 Py_CLEAR (self -> reader );
21452147 Py_CLEAR (self -> writer );
21462148 Py_CLEAR (self -> dict );
You can’t perform that action at this time.
0 commit comments