[issue23722] During metaclass.__init__, super() of the constructed class does not work

Nick Coghlan report at bugs.python.org
Sat Dec 3 01:45:19 EST 2016


Nick Coghlan added the comment:

Attached patch is some new test cases for an approach that I figured out *won't work*.

The problem I hit is that "__classcell__" is only injected into the class body execution namespace when there is at least one method implementation that needs it. In any other case, including when constructing types dynamically, it's entirely legitimate for it to be missing.

The attached draft test cases explored the idea of requiring that `__classcell__` be set to `None` to affirmatively indicate that it wasn't needed, but that would be a *major* compatibility break for dynamic type creation.

I haven't given up on providing that eager warning though - it should be possible to emit it in __build_class__ based on PyCell_GET returning NULL (as that should reliably indicate that type.__new__ never got access to the compiler provided cell object)

----------
Added file: http://bugs.python.org/file45736/issue23722_enhanced_classcell_tests.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23722>
_______________________________________


More information about the Python-bugs-list mailing list