[Python-Dev] type() does not call __prepare__?

2020年6月01日 12:23:10 -0700

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/

Reply via email to