[issue12370] Use of super overwrites use of __class__ in class namespace

2013-05-15 Thread Roundup Robot
Roundup Robot added the comment: New changeset 3d858f1eef54 by Benjamin Peterson in branch 'default': hide the __class__ closure from the class body (#12370) http://hg.python.org/cpython/rev/3d858f1eef54 -- ___ Python tracker rep...@bugs.python.org

[issue12370] Use of super overwrites use of __class__ in class namespace

2013-05-15 Thread Benjamin Peterson
Benjamin Peterson added the comment: Finally killed this one properly. -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12370 ___

[issue12370] Use of super overwrites use of __class__ in class namespace

2012-11-28 Thread Daniel Urban
Daniel Urban added the comment: Thanks for the review! Nick, the example with Outer, InnerParent and InnerChild still works (the evaluation happens before we enter the new scope). Of course you're all right about __args__ and __kw__. I'll try to find a way to hide them. -- stage:

[issue12370] Use of super overwrites use of __class__ in class namespace

2012-11-27 Thread Eric Snow
Eric Snow added the comment: I agree with Benjamin re: __args__ and __kw__. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12370 ___ ___

[issue12370] Use of super overwrites use of __class__ in class namespace

2012-11-27 Thread Nick Coghlan
Nick Coghlan added the comment: From a quick scan of the patch, I suspect the current implementation will also break this code: class Outer: class InnerParent: pass class InnerChild(InnerParent): pass The evaluation of the other args to build_class needs to happen before

[issue12370] Use of super overwrites use of __class__ in class namespace

2012-11-26 Thread Daniel Urban
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

[issue12370] Use of super overwrites use of __class__ in class namespace

2012-11-26 Thread Benjamin Peterson
Benjamin Peterson added the comment: The ability to close over __args__ and __kw__ in class methods is undesirable. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12370 ___

[issue12370] Use of super overwrites use of __class__ in class namespace

2012-10-03 Thread Nick Coghlan
Nick Coghlan added the comment: 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

[issue12370] Use of super overwrites use of __class__ in class namespace

2012-10-02 Thread Carsten Klein
Carsten Klein added the comment: The change was introduced in r30 (Python/symtable.c @ near where it reads /* Special-case super: it counts as a use of __class__ */) which now enforces that a class that calls super on init will have the correct class information present. I do not think that

[issue12370] Use of super overwrites use of __class__ in class namespace

2012-10-02 Thread Mark Shannon
Mark Shannon added the comment: There seems to be an ongoing confusion about scopes on this thread. The __class__ variable used by super() is a non-local variable in the scope of any function using super(), whereas the __class__ used to define the type of an object is a class attribute like

[issue12370] Use of super overwrites use of __class__ in class namespace

2012-09-07 Thread Nick Coghlan
Nick Coghlan added the comment: OK, I think I have a way to fix this that will actually *reduce* the level of special casing needed in the compiler. Specifically, I think we may be able to make the class statement emit *two* scopes, rather than the current one. The outer scope would be

[issue12370] Use of super overwrites use of __class__ in class namespace

2012-09-07 Thread Eric Snow
Eric Snow added the comment: Wouldn't the following also start working (currently a NameError)? class X: def f(self): print(f.__qualname__) def g(self): f(None) X().f() X().g() How about this[1] (also currently a NameError): class Outer: class

[issue12370] Use of super overwrites use of __class__ in class namespace

2012-09-07 Thread Eric Snow
Eric Snow added the comment: Actually, that second would still not work (it would have to pass through the non-lexical inner scope that Nick mentioned). Is that also the case for the first one? -- ___ Python tracker rep...@bugs.python.org

[issue12370] Use of super overwrites use of __class__ in class namespace

2012-09-07 Thread Nick Coghlan
Nick Coghlan added the comment: Yep. The only name in the new scope would be __class__. Everything else, including method names, should remain invisible from method bodies. I'm not 100% sure it will work as we want, but that's because I'm not sure if we can avoid causing a semantic change for

[issue12370] Use of super overwrites use of __class__ in class namespace

2012-09-07 Thread Eric Snow
Eric Snow added the comment: sounds like it would be worth a shot -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12370 ___ ___ Python-bugs-list

[issue12370] Use of super overwrites use of __class__ in class namespace

2012-07-31 Thread Chris Rebert
Changes by Chris Rebert pyb...@rebertia.com: -- nosy: +cvrebert ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12370 ___ ___ Python-bugs-list

[issue12370] Use of super overwrites use of __class__ in class namespace

2012-05-27 Thread Roundup Robot
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 96ab78ef82a7 by Nick Coghlan in branch 'default': Close #14857: fix regression in references to PEP 3135 implicit __class__ closure variable. Reopens issue #12370, but also updates unittest.mock to workaround that

[issue12370] Use of super overwrites use of __class__ in class namespace

2012-05-27 Thread Nick Coghlan
Nick Coghlan ncogh...@gmail.com added the comment: As the checkin message says, this is once again a problem on trunk. The relevant test is still in place in test_super.py, I just marked it as an expected failure. unittest.mock is currently avoiding the problem via the _safe_super = super

[issue12370] Use of super overwrites use of __class__ in class namespace

2012-05-27 Thread Meador Inge
Changes by Meador Inge mead...@gmail.com: -- nosy: +meador.inge ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12370 ___ ___ Python-bugs-list

[issue12370] Use of super overwrites use of __class__ in class namespace

2012-05-27 Thread Mark Shannon
Changes by Mark Shannon m...@hotpy.org: -- nosy: +Mark.Shannon ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12370 ___ ___ Python-bugs-list

[issue12370] Use of super overwrites use of __class__ in class namespace

2012-05-20 Thread Daniel Urban
Changes by Daniel Urban urban.dani...@gmail.com: -- nosy: +durban ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12370 ___ ___ Python-bugs-list

[issue12370] Use of super overwrites use of __class__ in class namespace

2012-05-20 Thread Arfrever Frehtes Taifersar Arahesis
Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com: -- nosy: +Arfrever ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12370 ___

[issue12370] Use of super overwrites use of __class__ in class namespace

2011-06-20 Thread Nick Coghlan
Nick Coghlan ncogh...@gmail.com added the comment: And to record the workaround for 3.1 and 3.2 (courtesy of Michael): Adding a _super = super alias at the module level and using the Python 2.x style long form invocation on _super() in affected methods will avoid the compiler games played

[issue12370] Use of super overwrites use of __class__ in class namespace

2011-06-20 Thread Barry A. Warsaw
Barry A. Warsaw ba...@python.org added the comment: That work around seems ugly. Why not back port the fix? It doesn't seem like it could break anything and it's not even arguably a new feature, right? -- nosy: +barry ___ Python tracker

[issue12370] Use of super overwrites use of __class__ in class namespace

2011-06-20 Thread Benjamin Peterson
Benjamin Peterson benja...@python.org added the comment: One reason is that it bumps the pyc magic number. -- nosy: +benjamin.peterson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12370 ___

[issue12370] Use of super overwrites use of __class__ in class namespace

2011-06-20 Thread Barry A. Warsaw
Barry A. Warsaw ba...@python.org added the comment: Ah okay, I didn't see that in the changeset. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12370 ___

[issue12370] Use of super overwrites use of __class__ in class namespace

2011-06-19 Thread Michael Foord
New submission from Michael Foord mich...@voidspace.org.uk: In Python 3 the following code prints False because the use of super() has caused the __class__ descriptor to be omitted from the class namespace. Remove the use of super and it prints True. class X(object): def

[issue12370] Use of super overwrites use of __class__ in class namespace

2011-06-19 Thread Alex Gaynor
Changes by Alex Gaynor alex.gay...@gmail.com: -- nosy: +alex ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12370 ___ ___ Python-bugs-list mailing

[issue12370] Use of super overwrites use of __class__ in class namespace

2011-06-19 Thread Roundup Robot
Roundup Robot devnull@devnull added the comment: New changeset 2d62ee4e7d98 by Benjamin Peterson in branch 'default': use a invalid name for the __class__ closure for super() (closes #12370) http://hg.python.org/cpython/rev/2d62ee4e7d98 -- nosy: +python-dev resolution: - fixed stage: