homepage

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日.16:34:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1639758868.86.0.300206982321.issue45383@roundup.psfhosted.org>
In-reply-to
Content
Well, what we need is a way to say: I am calling `type.__new__` (i.e. PyType_FromSpec) on purpose from (effectively) my own `mytype.__new__`?
That is, because right now I assume we want to protect users from calling PyType_FromSpec thinking that it is equivalent to calling `class new(base)` when it may not be if base is a metaclass. So calling `PyType_FromSpec` might refuse to work if it finds a custom `metaclass.__new__` (init?).
I don't really see that it matters if we only support effectively this from C:
```
class MyMetaClass(type):
 def __new__(cls, *args, **kwargs):
 self = type.__new__(...) # this is PyType_FromSpec
 # more stuff
```
So, I thought telling `PyType_FromSpec` that we are "inside" a custom `__new__` is sufficient and that even as a flag passed as part of the spec could be enough.
But... I agree that I do not quite see that it would be pretty, so it probably was a bad idea :).
Plus, if you add a new method it should also solves the issue of setting the `tp_type` slot to the metaclass explicitly when it is not implicit by inheritance (which is the only thing I care about).
(PyType_FromSpec and PyType_ApplySpec will still need to do the work of resolving the metaclass from the base classes, though.)
History
Date User Action Args
2021年12月17日 16:34:28sebergsetrecipients: + seberg, petr.viktorin
2021年12月17日 16:34:28sebergsetmessageid: <1639758868.86.0.300206982321.issue45383@roundup.psfhosted.org>
2021年12月17日 16:34:28seberglinkissue45383 messages
2021年12月17日 16:34:28sebergcreate

AltStyle によって変換されたページ (->オリジナル) /