]> 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:45:21 +0000 (14:45 +0200)
committerAntoine Pitrou <solipsis@pitrou.net>
Sat, 23 Jun 2012 12:45:21 +0000 (14:45 +0200)
1  2 
Misc/NEWS
Objects/typeobject.c

diff --cc Misc/NEWS
index f768602fd28a03358b3c1bb20ccba3164fe53585,6f59110039637bb4e09f5fb5db56967f1a745ecb..0325058e39c9891f3b201921811473e6ce727e4b
+++ b/Misc/NEWS
@@@ -10,9 -10,9 +10,12 @@@ What's New in Python 3.3.0 Beta 1
  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.
 +
  - Issue #10053: Don't close FDs when FileIO.__init__ fails. Loosely based on
    the work by Hirokazu Yamamoto.
  
index 872ed99568e9a9bfdae93c3f15dd4c9bf034b30f,54a990e01127e1654a4afd69126ab4a3def66774..d8bdeaf5d7eee9db163fba38de0594a091744c86
@@@ -2414,9 -2387,12 +2414,15 @@@ PyType_FromSpec(PyType_Spec *spec
              res->ht_type.tp_doc = tp_doc;
          }
      }
 +    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;