Message176429
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.) |
|
Date |
User |
Action |
Args |
2012-11-26 17:20:40 | daniel.urban | set | recipients:
+ 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:38 | daniel.urban | set | messageid: <1353950438.62.0.699340135179.issue12370@psf.upfronthosting.co.za> |
2012-11-26 17:20:38 | daniel.urban | link | issue12370 messages |
2012-11-26 17:20:37 | daniel.urban | create | |
|