Message408791
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. |
|
Date |
User |
Action |
Args |
2021-12-17 15:37:58 | seberg | set | recipients:
+ seberg, petr.viktorin |
2021-12-17 15:37:58 | seberg | set | messageid: <1639755478.75.0.398882645491.issue45383@roundup.psfhosted.org> |
2021-12-17 15:37:58 | seberg | link | issue45383 messages |
2021-12-17 15:37:58 | seberg | create | |
|