[issue43770] Rework C types initialization
STINNER Victor
report at bugs.python.org
Tue Apr 13 09:34:46 EDT 2021
STINNER Victor <vstinner at python.org> added the comment:
If I modify type_ready() to call type_ready_inherit() before type_ready_fill_dict(), some types create a between between their C slot (tp_init) and the Python API in tp_dict (tp_dict["__init__"]).
Example with importlib:
class FileLoader(...):
def __init__(...):
...
=> FileLoader.tp_init = slot_tp_init
class SourceFileLoader(FileLoader):
...
When PyType_Ready() is called on SourceFileLoader, we get:
* SourceFileLoader.tp_base = FileLoader
* SourceFileLoader.tp_init = NULL
* SourceFileLoader.tp_dict has no "__init__" key
When inherit_slots() is called, SourceFileLoader.tp_init is set to slot_tp_init().
When add_operators() is called, SourceFileLoader.tp_dict["__init__"] is set to PyDescr_NewWrapper(slot_tp_init).
Problem: we a loop! tp_dict["__init__"] => slot_tp_init => tp_dict["__init__"]
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43770>
_______________________________________
More information about the Python-bugs-list
mailing list