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 daniel.urban
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-11-26.17:20:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1353950438.62.0.699340135179.issue12370@psf.upfronthosting.co.za>
In-reply-to
Content
I tried to implement Nick's idea with the separate scope for __class__. It seems to work, I'm attaching a patch. The patch basically causes the following class statement:

class C(A, B, metaclass=meta):
    def f(self):
        return __class__

To be compiled approximately like this:

def _outer_C(*__args__, **__kw__):
    class _inner_C(*__args__, **__kw__):
        def f(self):
            return __class__
    __class__ = _inner_C
    return _inner_C
C = _outer_C(A, B, metaclass=meta)

It also includes some tests.

(The patch also changes the magic number in Lib/importlib/_bootstrap.py. This caused Python/importlib.h to be regenerated, but I didn't included those changes in the patch, because its a lot, and not very human-readable. Please tell me if I need to include them.)
History
Date User Action Args
2012-11-26 17:20:40daniel.urbansetrecipients: + daniel.urban, barry, ncoghlan, benjamin.peterson, Arfrever, alex, michael.foord, cvrebert, meador.inge, carsten.klein@axn-software.de, Mark.Shannon, python-dev, eric.snow
2012-11-26 17:20:38daniel.urbansetmessageid: <1353950438.62.0.699340135179.issue12370@psf.upfronthosting.co.za>
2012-11-26 17:20:38daniel.urbanlinkissue12370 messages
2012-11-26 17:20:37daniel.urbancreate