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 <rep...@bugs.python.org>
<http://bugs.python.org/issue23722>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to