Daniel Urban added the comment:
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.)
----------
components: +Interpreter Core
keywords: +needs review, patch
stage: needs patch -> patch review
versions: +Python 3.4
Added file: http://bugs.python.org/file28134/class_super_1.patch
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue12370>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com