[Python-checkins] cpython (merge 3.2 -> default): Issue #15142: Fix reference leak when deallocating instances of types created
antoine.pitrou
python-checkins at python.org
Sat Jun 23 14:48:55 CEST 2012
http://hg.python.org/cpython/rev/9945d7dfa72c
changeset: 77629:9945d7dfa72c
parent: 77627:837d51ba1aa2
parent: 77628:1794308c1ea7
user: Antoine Pitrou <solipsis at pitrou.net>
date: Sat Jun 23 14:45:21 2012 +0200
summary:
Issue #15142: Fix reference leak when deallocating instances of types created using PyType_FromSpec().
files:
Misc/NEWS | 3 +++
Objects/typeobject.c | 6 ++++++
2 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
Core and Builtins
-----------------
+- Issue #15142: Fix reference leak when deallocating instances of types
+ created using PyType_FromSpec().
+
- Issue #15042: Add PyState_AddModule and PyState_RemoveModule. Add version
guard for Py_LIMITED_API additions. Patch by Robin Schreiber.
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -2417,6 +2417,12 @@
if (res->ht_type.tp_dictoffset) {
res->ht_cached_keys = _PyDict_NewKeysForClass();
}
+ if (res->ht_type.tp_dealloc == NULL) {
+ /* It's a heap type, so needs the heap types' dealloc.
+ subtype_dealloc will call the base type's tp_dealloc, if
+ necessary. */
+ res->ht_type.tp_dealloc = subtype_dealloc;
+ }
if (PyType_Ready(&res->ht_type) < 0)
goto fail;
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list