[New-bugs-announce] [issue43770] Rework C types initialization

STINNER Victor report at bugs.python.org
Wed Apr 7 17:48:22 EDT 2021

New submission from STINNER Victor <vstinner at python.org>:

Currently, PyType_Ready() is called late on many static types, which can lead to bugs. For example, PyObject_SetAttr() can fail if the type of the object is not ready yet. PyType_Read() is responsible to initialize tp_getattro and tp_setattro members of the PyTypeObject structure.

We must explicitly initialize all static types before using them.

Moreover, many static types initialize explicitly :

  tp_getattro = PyObject_GenericGetAttr


  tp_setattro = PyObject_GenericSetAttr

whereas it's the default implementation. They can be omitted.

I created this issue as a placeholder for multiple changes to modify how types implemented in C are initialized.

components: Interpreter Core
messages: 390484
nosy: vstinner
priority: normal
severity: normal
status: open
title: Rework C types initialization
versions: Python 3.10

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list