Message192099
When using the three parameter form of type to create a new class, and any of the base classes has a metaclass with a __prepare__ function, the __prepare__ function is not executed:
>>> class CustomMetaclass(type):
... @classmethod
... def __prepare__(cls, name, bases):
... return { 'prepared_for': name }
...
>>> class ParentClass(metaclass=CustomMetaclass):
... pass
...
>>> class ClassOne(ParentClass):
... pass
...
>>> ClassTwo = type('ClassTwo', (ParentClass,), {})
>>> ClassOne.prepared_for
'ClassOne'
>>> ClassTwo.prepared_for
'ParentClass'
>>> 'prepared_for' in ClassOne.__dict__
True
>>> 'prepared_for' in ClassTwo.__dict__
False
I am not sure if that is intended behavior or not. I am attaching a doc patch for the case that this is intended. |
|
Date |
User |
Action |
Args |
2013-07-01 01:12:18 | nikratio | set | recipients:
+ nikratio |
2013-07-01 01:12:18 | nikratio | set | messageid: <1372641138.46.0.644775856541.issue18334@psf.upfronthosting.co.za> |
2013-07-01 01:12:18 | nikratio | link | issue18334 messages |
2013-07-01 01:12:18 | nikratio | create | |
|