File tree 3 files changed +11
-0
lines changed 3 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -1454,6 +1454,12 @@ def isatty(self):
1454
1454
pair = self .tp (SelectableIsAtty (True ), SelectableIsAtty (True ))
1455
1455
self .assertTrue (pair .isatty ())
1456
1456
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
+
1457
1463
class CBufferedRWPairTest (BufferedRWPairTest ):
1458
1464
tp = io .BufferedRWPair
1459
1465
Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ What's New in Python 3.2.6?
10
10
Library
11
11
-------
12
12
13
+ - Issue #22517: When a io.BufferedRWPair object is deallocated, clear its
14
+ weakrefs.
15
+
13
16
- Issue #16041: CVE-2013-1752: poplib: Limit maximum line lengths to 2048 to
14
17
prevent readline() calls from consuming too much memory. Patch by Jyrki
15
18
Pulliainen.
Original file line number Diff line number Diff line change @@ -2141,6 +2141,8 @@ static void
2141
2141
bufferedrwpair_dealloc (rwpair * self )
2142
2142
{
2143
2143
_PyObject_GC_UNTRACK (self );
2144
+ if (self -> weakreflist != NULL )
2145
+ PyObject_ClearWeakRefs ((PyObject * )self );
2144
2146
Py_CLEAR (self -> reader );
2145
2147
Py_CLEAR (self -> writer );
2146
2148
Py_CLEAR (self -> dict );
You can’t perform that action at this time.
0 commit comments