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 Arfrever, Mark.Shannon, alex, barry, benjamin.peterson, carsten.klein@axn-software.de, cvrebert, daniel.urban, eric.snow, meador.inge, michael.foord, ncoghlan, python-dev
Date 2012-10-03.08:48:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1349254111.21.0.88030439089.issue12370@psf.upfronthosting.co.za>
In-reply-to
Content
Carsten: emulating __class__ is necessary to implement proxy types (and similar utilities like mock objects) correctly. The difference between "x.__class__" is that proxies can remap it to the type of the referent, while "type(x)" will always report the real class of "x" (which may be a proxy like weakref.proxy, or a mock object, as it is in the case Michael is interested in).

Mark: correct, the problem is that the compiler is treating *all* references to __class__ inside a class body as references to the cell variable, when it should really only be doing that for references inside methods - references directly at the class body level should still be to the entry in the class locals namespace that later become attributes of the class object. Hence my idea of introducing a separate closure namespace encapsulating the class namespace to separate the two more cleanly than the current hacky override.
History
Date User Action Args
2012-10-03 08:48:31ncoghlansetrecipients: + ncoghlan, barry, benjamin.peterson, Arfrever, alex, michael.foord, cvrebert, meador.inge, daniel.urban, carsten.klein@axn-software.de, Mark.Shannon, python-dev, eric.snow
2012-10-03 08:48:31ncoghlansetmessageid: <1349254111.21.0.88030439089.issue12370@psf.upfronthosting.co.za>
2012-10-03 08:48:31ncoghlanlinkissue12370 messages
2012-10-03 08:48:30ncoghlancreate