[Patches] [ python-Patches-1727209 ] First steps towards new super (PEP 367)

SourceForge.net noreply at sourceforge.net
Thu May 31 13:45:18 CEST 2007


Patches item #1727209, was opened at 2007-05-28 22:30
Message generated for change (Comment added) made by gvanrossum
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1727209&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Core (C code)
Group: Python 3000
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Guido van Rossum (gvanrossum)
Assigned to: Guido van Rossum (gvanrossum)
Summary: First steps towards new super (PEP 367)

Initial Comment:
A half-assed start of an implementation for super.

This is lacking parser support; instead, for now, you have to have a keyword-only argument named super, e.g.

def foo(self, arg, *, super):
    return super.foo(arg) + 1

Note that the first version changes method lookup for bound method lookup but not yet for unbound method lookup.  E.g. if f is defined in class B, and class C derives from B, C().f returns a bound method object whose im_class attribute is set to B (as opposed to C as it used to be) but C.f returns an unbound method object with im_class set to C.  (I hope to this in a later version.)

----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2007-05-31 07:45

Message:
Logged In: YES 
user_id=6380
Originator: YES

Oops, a last-minute change didn't work out.  This version is better.
File Added: super.diff

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2007-05-31 07:24

Message:
Logged In: YES 
user_id=6380
Originator: YES

Here's a version that modifies the grammar so 'super' is a keyword. The
compiler automatically inserts a 'super' keyword-only argument into a
function's signature when the 'super' keyword is used in its body.  It
works!

This requires the p3yk branch at -r55692 or newer.
File Added: super.diff

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2007-05-29 02:08

Message:
Logged In: YES 
user_id=6380
Originator: YES

Here's a new version.  Forget about sup.py, the demos are now in
Lib/test/test_super.py.

Only a few tests fail due to the semantic change (about six files have 1-2
failures each).  I think this is acceptable.

File Added: super.diff

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2007-05-28 23:23

Message:
Logged In: YES 
user_id=6380
Originator: YES

And a new sup.py example demonstrating that the new patch works.
File Added: sup.py

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2007-05-28 23:22

Message:
Logged In: YES 
user_id=6380
Originator: YES

Here's a new version of the patch where C.f.im_class (in the above
example) correctly returns B.
File Added: super.diff

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2007-05-28 22:31

Message:
Logged In: YES 
user_id=6380
Originator: YES

Here is sup.py, a small demo of how this is supposed to work.
File Added: sup.py

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1727209&group_id=5470


More information about the Patches mailing list