- super() no longer ignores data descriptors, except __class__. See
the thread started at http://mail.python.org/pipermail/python-dev/2003-April/034338.html
This commit is contained in:
parent
6cc5bb685d
commit
a4541a30fc
|
@ -1989,7 +1989,7 @@ def supers():
|
||||||
|
|
||||||
class F(E):
|
class F(E):
|
||||||
def meth(self, a):
|
def meth(self, a):
|
||||||
s = self.__super
|
s = self.__super # == mysuper(F, self)
|
||||||
return "F(%r)[%s]" % (a, s.__class__.__name__) + s.meth(a)
|
return "F(%r)[%s]" % (a, s.__class__.__name__) + s.meth(a)
|
||||||
F._F__super = mysuper(F)
|
F._F__super = mysuper(F)
|
||||||
|
|
||||||
|
@ -2025,6 +2025,21 @@ def supers():
|
||||||
else:
|
else:
|
||||||
raise TestFailed, "shouldn't allow super(D).__get__(C())"
|
raise TestFailed, "shouldn't allow super(D).__get__(C())"
|
||||||
|
|
||||||
|
# Make sure data descriptors can be overridden and accessed via super
|
||||||
|
# (new feature in Python 2.3)
|
||||||
|
|
||||||
|
class DDbase(object):
|
||||||
|
def getx(self): return 42
|
||||||
|
x = property(getx)
|
||||||
|
|
||||||
|
class DDsub(DDbase):
|
||||||
|
def getx(self): return "hello"
|
||||||
|
x = property(getx)
|
||||||
|
|
||||||
|
dd = DDsub()
|
||||||
|
vereq(dd.x, "hello")
|
||||||
|
vereq(super(DDsub, dd).x, 42)
|
||||||
|
|
||||||
def inherits():
|
def inherits():
|
||||||
if verbose: print "Testing inheritance from basic types..."
|
if verbose: print "Testing inheritance from basic types..."
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue