[Python-checkins] cpython (merge 3.3 -> 3.4): merge 3.3 (#22517)
benjamin.peterson
python-checkins at python.org
Tue Sep 30 04:49:41 CEST 2014
https://hg.python.org/cpython/rev/e54da75100f6
changeset: 92646:e54da75100f6
branch: 3.4
parent: 92641:158127da99ac
parent: 92645:e834b32f0422
user: Benjamin Peterson <benjamin at python.org>
date: Mon Sep 29 22:48:51 2014 -0400
summary:
merge 3.3 (#22517)
files:
Lib/test/test_io.py | 6 ++++++
Misc/NEWS | 3 +++
Modules/_io/bufferedio.c | 2 ++
3 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -1567,6 +1567,12 @@
pair = self.tp(SelectableIsAtty(True), SelectableIsAtty(True))
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):
tp = io.BufferedRWPair
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -16,6 +16,9 @@
Library
-------
+- Issue #22517: When a io.BufferedRWPair object is deallocated, clear its
+ weakrefs.
+
- Issue #22448: Improve canceled timer handles cleanup to prevent
unbound memory usage. Patch by Joshua Moore-Oliva.
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c
--- a/Modules/_io/bufferedio.c
+++ b/Modules/_io/bufferedio.c
@@ -2297,6 +2297,8 @@
bufferedrwpair_dealloc(rwpair *self)
{
_PyObject_GC_UNTRACK(self);
+ if (self->weakreflist != NULL)
+ PyObject_ClearWeakRefs((PyObject *)self);
Py_CLEAR(self->reader);
Py_CLEAR(self->writer);
Py_CLEAR(self->dict);
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list