It's not a bug, it's just bypassing steps in the Py3 dynamic class definition process.
https://docs.python.org/3/library/types.html#types.new_class is the API to use to invoke the full metaclass machinery, including namespace preparation. https://docs.python.org/3/reference/datamodel.html#metaclasses goes into more detail on how that works (calling the metaclass constructor is the last step, after the namespace has already been prepared and populated). Cheers, Nick. On Tue., 2 Jun. 2020, 5:22 am Ethan Furman, <[email protected]> wrote: > From stackoverflow [1] > > # metaprepare.py > class Meta1(type): > @classmethod > def __prepare__(mcs, name, bases): > print('call prepare') > return {} > def __new__(mcs, name, bases, parameters): > return super().__new__(mcs, name, bases, parameters) > > class A(metaclass=Meta1): > pass > > type('C', (A, ), {}) > > output is: > > call prepare > > (just the once, not twice) > > The behavior of `type()` not calling `__prepare__()` has been constant > since 3.3. > > Is it a bug? > > > -- > ~Ethan~ > > > [1] https://stackoverflow.com/q/62128254/208880 > _______________________________________________ > Python-Dev mailing list -- [email protected] > To unsubscribe send an email to [email protected] > https://mail.python.org/mailman3/lists/python-dev.python.org/ > Message archived at > https://mail.python.org/archives/list/[email protected]/message/CQTD7WFOIDBF5PSD77AALBTWJQ67UPM5/ > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-Dev mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/SMBMNS6H76BJ4SQBDY7XV5YWQFYSCBWK/ Code of Conduct: http://python.org/psf/codeofconduct/
