mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
merge 3.3 (#22517)
This commit is contained in:
commit
c44eb73473
3 changed files with 11 additions and 0 deletions
|
@ -1567,6 +1567,12 @@ class BufferedRWPairTest(unittest.TestCase):
|
||||||
pair = self.tp(SelectableIsAtty(True), SelectableIsAtty(True))
|
pair = self.tp(SelectableIsAtty(True), SelectableIsAtty(True))
|
||||||
self.assertTrue(pair.isatty())
|
self.assertTrue(pair.isatty())
|
||||||
|
|
||||||
|
def test_weakref_clearing(self):
|
||||||
|
brw = self.tp(self.MockRawIO(), self.MockRawIO())
|
||||||
|
ref = weakref.ref(brw)
|
||||||
|
brw = None
|
||||||
|
ref = None # Shouldn't segfault.
|
||||||
|
|
||||||
class CBufferedRWPairTest(BufferedRWPairTest):
|
class CBufferedRWPairTest(BufferedRWPairTest):
|
||||||
tp = io.BufferedRWPair
|
tp = io.BufferedRWPair
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #22517: When a io.BufferedRWPair object is deallocated, clear its
|
||||||
|
weakrefs.
|
||||||
|
|
||||||
- Issue #22448: Improve canceled timer handles cleanup to prevent
|
- Issue #22448: Improve canceled timer handles cleanup to prevent
|
||||||
unbound memory usage. Patch by Joshua Moore-Oliva.
|
unbound memory usage. Patch by Joshua Moore-Oliva.
|
||||||
|
|
||||||
|
|
|
@ -2297,6 +2297,8 @@ static void
|
||||||
bufferedrwpair_dealloc(rwpair *self)
|
bufferedrwpair_dealloc(rwpair *self)
|
||||||
{
|
{
|
||||||
_PyObject_GC_UNTRACK(self);
|
_PyObject_GC_UNTRACK(self);
|
||||||
|
if (self->weakreflist != NULL)
|
||||||
|
PyObject_ClearWeakRefs((PyObject *)self);
|
||||||
Py_CLEAR(self->reader);
|
Py_CLEAR(self->reader);
|
||||||
Py_CLEAR(self->writer);
|
Py_CLEAR(self->writer);
|
||||||
Py_CLEAR(self->dict);
|
Py_CLEAR(self->dict);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue