summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-11-14 23:32:33 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-11-14 23:32:33 (GMT)
commita91e9646e0f916498e812de467f8ac50574e22b1 (patch)
treef267e1712283f445ee74fd7b9b7aa6364dd00038 /Lib
parente1d4ad3a31b567e69d6d7c441ce70cd35ba59364 (diff)
downloadcpython-a91e9646e0f916498e812de467f8ac50574e22b1.zip
cpython-a91e9646e0f916498e812de467f8ac50574e22b1.tar.gz
cpython-a91e9646e0f916498e812de467f8ac50574e22b1.tar.bz2
Changing diapers reminded Guido that he wanted to allow for some measure
of multiple inheritance from a mix of new- and classic-style classes. This is his patch, plus a start at some test cases from me. Will check in more, plus a NEWS blurb, later tonight.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_descr.py55
1 files changed, 47 insertions, 8 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index ca09ca9..cf7ef2d 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -829,6 +829,53 @@ def multi():
vereq(Frag().__int__(), 42)
vereq(int(Frag()), 42)
+ # MI mixing classic and new-style classes.
+ class C:
+ def cmethod(self):
+ return "C a"
+ def all_method(self):
+ return "C b"
+
+ class M1(C, object):
+ def m1method(self):
+ return "M1 a"
+ def all_method(self):
+ return "M1 b"
+
+ vereq(M1.__mro__, (M1, C, object))
+ m = M1()
+ vereq(m.cmethod(), "C a")
+ vereq(m.m1method(), "M1 a")
+ vereq(m.all_method(), "M1 b")
+
+ class D(C):
+ def dmethod(self):
+ return "D a"
+ def all_method(self):
+ return "D b"
+
+ class M2(object, D):
+ def m2method(self):
+ return "M2 a"
+ def all_method(self):
+ return "M2 b"
+
+ vereq(M2.__mro__, (M2, object, D, C))
+ m = M2()
+ vereq(m.cmethod(), "C a")
+ vereq(m.dmethod(), "D a")
+ vereq(m.m2method(), "M2 a")
+ vereq(m.all_method(), "M2 b")
+
+ class M3(M1, object, M2):
+ def m3method(self):
+ return "M3 a"
+ def all_method(self):
+ return "M3 b"
+ # XXX Expected this (the commented-out result):
+ # vereq(M3.__mro__, (M3, M1, M2, object, D, C))
+ vereq(M3.__mro__, (M3, M1, M2, D, C, object)) # XXX ?
+
def diamond():
if verbose: print "Testing multiple inheritance special cases..."
class A(object):
@@ -1017,14 +1064,6 @@ def errors():
pass
try:
- class C(object, Classic):
- pass
- except TypeError:
- pass
- else:
- verify(0, "inheritance from object and Classic should be illegal")
-
- try:
class C(type(len)):
pass
except TypeError: