[New-bugs-announce] [issue15142] Fix reference leak with types created using PyType_FromSpec

Antoine Pitrou report at bugs.python.org
Fri Jun 22 21:56:07 CEST 2012


New submission from Antoine Pitrou <pitrou at free.fr>:

The following patch seems to fix the issue explained in http://mail.python.org/pipermail/python-dev/2012-June/120659.html :


diff --git a/Objects/typeobject.c b/Objects/typeobject.c
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -2417,6 +2417,10 @@ PyType_FromSpec(PyType_Spec *spec)
     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 */
+        res->ht_type.tp_dealloc = subtype_dealloc;
+    }
 
     if (PyType_Ready(&res->ht_type) < 0)
         goto fail;

----------
components: Interpreter Core
messages: 163470
nosy: loewis, pitrou
priority: normal
severity: normal
stage: patch review
status: open
title: Fix reference leak with types created using PyType_FromSpec
type: resource usage
versions: Python 3.2, Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15142>
_______________________________________


More information about the New-bugs-announce mailing list