Closed
Description
When Py_TPFLAGS_BASETYPE
and Py_TPFLAGS_DISALLOW_INSTANTIATION
flags are set on extension type tp_flags
field, attempt to create type subclass instance fails:
>>> import _foo
>>> class Bar(_foo.Foo): pass
...
>>> Bar()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: cannot create 'Bar' instances
According to documentation, it shouldn't happen:
https://docs.python.org/3/c-api/typeobj.html#Py_TPFLAGS_DISALLOW_INSTANTIATION
Extension code example:
_foo.c.txt
Tested on 3.10.3 and 3.12.0a0.