This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Super method search quirk
Type: Stage:
Components: Interpreter Core Versions: Python 2.2
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: glchapman, gvanrossum, nascheme
Priority: normal Keywords:

Created on 2002-01-17 19:14 by glchapman, last changed 2022-04-10 16:04 by admin. This issue is now closed.

Messages (4)
msg8823 - (view) Author: Greg Chapman (glchapman) Date: 2002-01-17 19:14
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

msg8824 - (view) Author: Neil Schemenauer (nascheme) * (Python committer) Date: 2002-03-22 22:27
Logged In: YES 
user_id=35752

I agree.  This looks like a bug with super().
msg8825 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-03-22 22:34
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.
msg8826 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-03-23 03:49
Logged In: YES 
user_id=6380

Closing as Rejected.
History
Date User Action Args
2022-04-10 16:04:53adminsetgithub: 35937
2002-01-17 19:14:20glchapmancreate