This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients Martin.Teichmann, ncoghlan, petr.viktorin, yselivanov
Date 2018-03-29.14:52:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1522335149.82.0.467229070634.issue33179@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2018-03-29 14:52:29ncoghlansetrecipients: + ncoghlan, petr.viktorin, yselivanov, Martin.Teichmann
2018-03-29 14:52:29ncoghlansetmessageid: <1522335149.82.0.467229070634.issue33179@psf.upfronthosting.co.za>
2018-03-29 14:52:29ncoghlanlinkissue33179 messages
2018-03-29 14:52:29ncoghlancreate