From: Antoine Pitrou Date: Sat, 23 Jun 2012 12:45:21 +0000 (+0200) Subject: Issue #15142: Fix reference leak when deallocating instances of types created using... X-Git-Tag: v3.3.0b1~125 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a4db02c7a38c5669b5678f1e972d8b9c6d3a2238;p=python Issue #15142: Fix reference leak when deallocating instances of types created using PyType_FromSpec(). --- a4db02c7a38c5669b5678f1e972d8b9c6d3a2238 diff --cc Misc/NEWS index f768602fd2,6f59110039..0325058e39 --- a/Misc/NEWS +++ 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. diff --cc Objects/typeobject.c index 872ed99568,54a990e011..d8bdeaf5d7 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@@ -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;