[Python-bugs-list] [ python-Bugs-505028 ] Super method search quirk
noreply@sourceforge.net
noreply@sourceforge.net
Fri, 22 Mar 2002 14:34:25 -0800
Bugs item #505028, was opened at 2002-01-17 14:14
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=505028&group_id=5470
Category: Type/class unification
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Greg Chapman (glchapman)
Assigned to: Guido van Rossum (gvanrossum)
Summary: Super method search quirk
Initial Comment:
I think the following qualifies as a bug; I think the
call to super(C, self).m() should cause an exception
(the super_getattro search should not find the m in A
if an m is defined in B):
>>> class A(object):
... def m(self):
... print 'A'
...
>>> class B(A):
... m = property(lambda self: 'B')
...
>>> class C(B):
... def m(self):
... super(C, self).m()
... print 'C'
...
>>> c = C()
>>> c.meth()
A
C
----------------------------------------------------------------------
>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-03-22 17:34
Message:
Logged In: YES
user_id=6380
It would seem a bug, but according to the CVS log it's
intentional. typeobject.c 2.120 introduces an explicit check
that skips data descriptors (such as properties). The
motivation:
- super(C, C()).__class__ would return the __class__
attribute of C()
rather than the __class__ attribute of the super object.
This is
confusing. To fix this, I decided to change the semantics
of super
so that it only applies to code attributes, not to data
attributes.
After all, overriding data attributes is not supported
anyway.
So I think this is a feature after all.
----------------------------------------------------------------------
Comment By: Neil Schemenauer (nascheme)
Date: 2002-03-22 17:27
Message:
Logged In: YES
user_id=35752
I agree. This looks like a bug with super().
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=505028&group_id=5470