New submission from Nikolaus Rath: 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. ---------- components: Interpreter Core files: type_doc_patch.diff keywords: patch messages: 192099 nosy: Nikratio priority: normal severity: normal status: open title: type(name, bases, dict) does not call metaclass' __prepare__ attribute type: behavior versions: Python 3.3 Added file: http://bugs.python.org/file30737/type_doc_patch.diff _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18334> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com