]> granicus.if.org Git - python/commitdiff
- super() no longer ignores data descriptors, except __class__. See
authorGuido van Rossum <guido@python.org>
Wed, 16 Apr 2003 20:02:22 +0000 (20:02 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 16 Apr 2003 20:02:22 +0000 (20:02 +0000)
  the thread started at
  http://mail.python.org/pipermail/python-dev/2003-April/034338.html

Lib/test/test_descr.py

index 4a9cc50a20de48f4a4a6d471b8c6187126e8990b..972e22401ae8a58863d2116610e9f06ae53f39ee 100644 (file)
@@ -1989,7 +1989,7 @@ def supers():
 
     class F(E):
         def meth(self, a):
-            s = self.__super
+            s = self.__super # == mysuper(F, self)
             return "F(%r)[%s]" % (a, s.__class__.__name__) + s.meth(a)
     F._F__super = mysuper(F)
 
@@ -2025,6 +2025,21 @@ def supers():
     else:
         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():
     if verbose: print "Testing inheritance from basic types..."