Message314654
Note that this isn't about the __class__ reference itself - that would still be a closure cell.
This issue is about the fact that since Python 3.6, type.__new__ has handled calling __set_name__ on all the descriptors, so __build_class__ needs a way to pass the cell over to type.__new__.
Currently, the channel for that is the class body execution namespace itself, which created a new requirement for metaclasses to ensure that the "__classcell__" entry actually makes it all the way to "type.__new__". Django at least had to make changes to account for that, and it's mildly disappointing to be imposing that requirement on library and framework authors solely because of a technical limitation in CPython.
Even without context chaining, it seems to me that nesting of class definitions could be handled by making the context variable a list of cell objects and having type.__new__ look at the final entry rather than the whole thing. |
|
Date |
User |
Action |
Args |
2018-03-29 14:52:29 | ncoghlan | set | recipients:
+ ncoghlan, petr.viktorin, yselivanov, Martin.Teichmann |
2018-03-29 14:52:29 | ncoghlan | set | messageid: <1522335149.82.0.467229070634.issue33179@psf.upfronthosting.co.za> |
2018-03-29 14:52:29 | ncoghlan | link | issue33179 messages |
2018-03-29 14:52:29 | ncoghlan | create | |
|