summaryrefslogtreecommitdiffstats
path: root/Objects/codeobject.c
diff options
context:
space:
mode:
authorPetr Viktorin <encukou@gmail.com>2019-09-12 09:44:46 (GMT)
committerGitHub <noreply@github.com>2019-09-12 09:44:46 (GMT)
commit3562ae25402aad36583bc27d4d82c67554323d5e (patch)
treebf0b4ffda88bfeaf218446ee972ec3bbd9e70d3b /Objects/codeobject.c
parenteb19c45298361d75f744dcda295fa635a8490c3c (diff)
downloadcpython-3562ae25402aad36583bc27d4d82c67554323d5e.zip
cpython-3562ae25402aad36583bc27d4d82c67554323d5e.tar.gz
cpython-3562ae25402aad36583bc27d4d82c67554323d5e.tar.bz2
[3.8] bpo-37879: Suppress subtype_dealloc decref when base type is a C heap type (GH-15323, GH-16004) (GH-15966)
The instance destructor for a type is responsible for preparing an instance for deallocation by decrementing the reference counts of its referents. If an instance belongs to a heap type, the type object of an instance has its reference count decremented while for static types, which are permanently allocated, the type object is unaffected by the instance destructor. Previously, the default instance destructor searched the class hierarchy for an inherited instance destructor and, if present, would invoke it. Then, if the instance type is a heap type, it would decrement the reference count of that heap type. However, this could result in the premature destruction of a type because the inherited instance destructor should have already decremented the reference count of the type object. This change avoids the premature destruction of the type object by suppressing the decrement of its reference count when an inherited, non-default instance destructor has been invoked. Finally, an assertion on the Py_SIZE of a type was deleted. Heap types have a non zero size, making this into an incorrect assertion. https://github.com/python/cpython/pull/15323. (cherry picked from commit ff023ed36ea260ab64be5895f1f1f087c798987a) Fixup: https://github.com/python/cpython/pull/16004. (cherry picked from commit 5e9caeec76119a0d61c25f1466c27b7dbd5115bd) Co-authored-by: Eddie Elizondo <eduardo.elizondorueda@gmail.com>
Diffstat (limited to 'Objects/codeobject.c')
0 files changed, 0 insertions, 0 deletions