]> granicus.if.org Git - python/commitdiff
Issue #15142: Fix reference leak when deallocating instances of types created using...
authorAntoine Pitrou <solipsis@pitrou.net>
Sat, 23 Jun 2012 12:42:38 +0000 (14:42 +0200)
committerAntoine Pitrou <solipsis@pitrou.net>
Sat, 23 Jun 2012 12:42:38 +0000 (14:42 +0200)
Misc/NEWS
Objects/typeobject.c

index 789f7f78bb4681b20f4416466814916dd7438f2b..6f59110039637bb4e09f5fb5db56967f1a745ecb 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@ What's New in Python 3.2.4
 Core and Builtins
 -----------------
 
+- Issue #15142: Fix reference leak when deallocating instances of types
+  created using PyType_FromSpec().
+
 - Issue #10053: Don't close FDs when FileIO.__init__ fails. Loosely based on
   the work by Hirokazu Yamamoto.
 
index 934d06f7720f039c034e838fcd5edf833f1cbf42..54a990e01127e1654a4afd69126ab4a3def66774 100644 (file)
@@ -2387,6 +2387,12 @@ PyType_FromSpec(PyType_Spec *spec)
             res->ht_type.tp_doc = tp_doc;
         }
     }
+    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;