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 nikratio
Recipients nikratio
Date 2013-07-01.01:12:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1372641138.46.0.644775856541.issue18334@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2013-07-01 01:12:18nikratiosetrecipients: + nikratio
2013-07-01 01:12:18nikratiosetmessageid: <1372641138.46.0.644775856541.issue18334@psf.upfronthosting.co.za>
2013-07-01 01:12:18nikratiolinkissue18334 messages
2013-07-01 01:12:18nikratiocreate