Bug report
Bug description:
# `metaclass_instance == np.dtype` for NumPy main type("name", metaclass_instance, {})
for metaclasses that have tp_new == NULL is well defined: It has to be a Python error just like:
>>> type(metaclass_instace)()
TypeError: cannot create 'numpy._DTypeMeta' instances
(in this case a NumPy metaclass, but you need the main branch of NumPy to test this.)
That is, a metaclass that is a valid baseclass in C but has tp_new == NULL cannot be instantiated from Python but hits this code branch:
Line 5029 in 94a64bb
| *type = winner->tp_new(winner, ctx->args, ctx->kwds); |
Which clearly segfaults for tp_new == NULL.
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
- gh-151912: Fix segfault in
type()with NULLtp_newmetaclasses #151916 - [3.14] gh-151912: Fix segfault in
type()with NULLtp_newmetaclasses (GH-151916) #153705 - [3.13] gh-151912: Fix segfault in
type()with NULLtp_newmetaclasses (GH-151916) #153706 - [3.15] gh-151912: Fix segfault in
type()with NULLtp_newmetaclasses (GH-151916) #153707