[New-bugs-announce] [issue34522] PyTypeObject's tp_base initialization bug

Eddie Elizondo report at bugs.python.org
Mon Aug 27 16:25:41 EDT 2018


New submission from Eddie Elizondo <eduardo.elizondorueda at gmail.com>:

>From the documentation, it says that PyType_Ready should be called on `ALL` type objects to finish their initialization (https://docs.python.org/3/c-api/type.html#c.PyType_Ready). This means that a PyTypeObject's ob_type should always be set by PyType_Ready.

It turns out that this is not actually followed by all the core types in CPython. This leads to the usage of types that were not initialized through PyType_Ready.

This fix modifies PyVarObject_HEAD_INIT to default the type to NULL so that all objects have to be fully initialized through PyType_Ready.

Plus:
* It initializes all the objects that were not being initialized through PyType_Ready.
* Modifies PyType_Ready to special case the ob_type initialization of PyType_Type and PyBaseObject_Type.
* It modifies the edge case of _Py_FalseStruct and _Py_TrueStruct.

Read more: https://mail.python.org/pipermail/python-dev/2018-August/154946.html

----------
components: Interpreter Core
messages: 324195
nosy: eelizondo
priority: normal
severity: normal
status: open
title: PyTypeObject's tp_base initialization bug
type: behavior
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34522>
_______________________________________


More information about the New-bugs-announce mailing list