This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author seberg
Recipients petr.viktorin, seberg
Date 2021-12-17.15:37:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1639755478.75.0.398882645491.issue45383@roundup.psfhosted.org>
In-reply-to
Content
Fully, agree!  In the end, `PyType_FromSpec` replaces `type.__new__()` (and init I guess) when working in C.  In Python, we would call `type.__new__` (maybe via super) from the `metatype.__new__`, but right now, in C, the metatype cannot reliably use `PyType_FromSpec` in its own `metatype.__new__` to do the same.

I agree with the scenarios:
* If we do not have a custom `metatype.__new__` (init?) then `PyType_FromSpec` should have no reason to refuse doing the work, because nothing can go wrong.
* If we do have a custom `tp_new` the user has to provide C API to create the metaclass instance.  But they still need a way to call `type.__new__` in C (i.e. get what `PyType_FromSpec` does, and promising to do the rest).

`PyType_ApplySpec` would provide that way to create a custom `metatype.__new__` in C when `PyType_FromSpec()` would otherwise reject it to make the first scenario safe.
A flag probably can do the same.  I have no preference, `ApplySpec` seems great to me.
History
Date User Action Args
2021-12-17 15:37:58sebergsetrecipients: + seberg, petr.viktorin
2021-12-17 15:37:58sebergsetmessageid: <1639755478.75.0.398882645491.issue45383@roundup.psfhosted.org>
2021-12-17 15:37:58seberglinkissue45383 messages
2021-12-17 15:37:58sebergcreate