[issue28437] Class definition is not consistent with types.new_class

2016-10-15 Thread Neil Girdhar
Neil Girdhar added the comment: "As a result of this, *both* implementations include a conditional check for a more derived metaclass in their namespace preparation logic, as well as an unconditional call to that metaclass derivation logic from type_new if the calculated metaclass is either ty

[issue28437] Class definition is not consistent with types.new_class

2016-10-15 Thread Neil Girdhar
Neil Girdhar added the comment: >From your comment: >>> MyDerivedDynamic = new_class("MyDerivedDynamic", (MyClass,), >>> dict(metaclass=metaclass_callable)) Traceback (most recent call last): File "", line 1, in File "/usr/lib64/python3.5/types.py", line 57, in new_class return meta(na

[issue28437] Class definition is not consistent with types.new_class

2016-10-15 Thread Neil Girdhar
Neil Girdhar added the comment: The documentation suggests that you can have a metaclass that does is not the "most derived metaclass" provided you specify one that is not an instance of type. This doesn't work in CPython, so I would suggest fixing the documentation using the text I provided.

[issue28437] Class definition is not consistent with types.new_class

2016-10-15 Thread Nick Coghlan
Nick Coghlan added the comment: (I'll also note that my final comment there is rather different from my first draft, as I almost forgot myself that the namespace preparation logic lives in __build_class__ rather than type_new. Class definitions can actually bypass type entirely, even in Python

[issue28437] Class definition is not consistent with types.new_class

2016-10-15 Thread Nick Coghlan
Nick Coghlan added the comment: Note: I'd be open to suggestions for comments in the pure Python implementation that would have helped you find its CPython counterpart in bltinmodule.c - it isn't immediately obvious from the current code that the actual __build_class__ code invoked by CPython'

[issue28437] Class definition is not consistent with types.new_class

2016-10-15 Thread Nick Coghlan
Nick Coghlan added the comment: I'm not clear on what discrepancy you're referring to, as I get the same (expected) exception for both the class statement and the dynamic type creation: >>> class MyDerived(MyClass, metaclass=metaclass_callable): ... pass ... Traceback (most recent call las

[issue28437] Class definition is not consistent with types.new_class

2016-10-15 Thread Nick Coghlan
Changes by Nick Coghlan : -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker ___ ___ Python-bu

[issue28437] Class definition is not consistent with types.new_class

2016-10-14 Thread Nick Coghlan
Changes by Nick Coghlan : -- nosy: +ncoghlan ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pytho

[issue28437] Class definition is not consistent with types.new_class

2016-10-13 Thread Neil Girdhar
Neil Girdhar added the comment: Oops, I meant: MyDerived = new_class("MyDerived", (MyClass,), dict(metaclass=metaclass_callable)) Nevertheless, the exception line number is totally off because it's tripping in the C code rather than in the Python code of the types library. -- __

[issue28437] Class definition is not consistent with types.new_class

2016-10-13 Thread Neil Girdhar
New submission from Neil Girdhar: Minimum working example: class MyMetaclass(type): pass class OtherMetaclass(type): pass def metaclass_callable(name, bases, namespace): return OtherMetaclass(name, bases, namespace) class MyClass(metaclass=MyMetaclass): pass try: class My