diff options
author | Eddie Elizondo <eduardo.elizondorueda@gmail.com> | 2019-09-11 09:17:13 (GMT) |
---|---|---|
committer | Petr Viktorin <encukou@gmail.com> | 2019-09-11 09:17:13 (GMT) |
commit | ff023ed36ea260ab64be5895f1f1f087c798987a (patch) | |
tree | dd5e417057ca8cc75876ddda2b292bcce727e249 /Misc | |
parent | 7264e92b718d307cc499b2f10eab7644b00f0499 (diff) | |
download | cpython-ff023ed36ea260ab64be5895f1f1f087c798987a.zip cpython-ff023ed36ea260ab64be5895f1f1f087c798987a.tar.gz cpython-ff023ed36ea260ab64be5895f1f1f087c798987a.tar.bz2 |
bpo-37879: Suppress subtype_dealloc decref when base type is a C heap type (GH-15323)
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
Diffstat (limited to 'Misc')
-rw-r--r-- | Misc/NEWS.d/next/C API/2019-08-17-13-50-21.bpo-37879.CZeUem.rst | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/C API/2019-08-17-13-50-21.bpo-37879.CZeUem.rst b/Misc/NEWS.d/next/C API/2019-08-17-13-50-21.bpo-37879.CZeUem.rst new file mode 100644 index 0000000..87322fb --- /dev/null +++ b/Misc/NEWS.d/next/C API/2019-08-17-13-50-21.bpo-37879.CZeUem.rst @@ -0,0 +1,2 @@ +Fix subtype_dealloc to suppress the type decref when the base type is a C +heap type |