summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2005-12-29 17:07:39 (GMT)
committerArmin Rigo <arigo@tunes.org>2005-12-29 17:07:39 (GMT)
commit037d1e0ff38f4ae2867c4b90d263ecd8aa2df585 (patch)
tree327d4acac79a49988505edca603e7475833a3d87 /Lib
parentf5bd3b442dd378563036f51595a7d6b2a239f4d5 (diff)
downloadcpython-037d1e0ff38f4ae2867c4b90d263ecd8aa2df585.zip
cpython-037d1e0ff38f4ae2867c4b90d263ecd8aa2df585.tar.gz
cpython-037d1e0ff38f4ae2867c4b90d263ecd8aa2df585.tar.bz2
SF bug #1153075: "PyXxx_Check(x) trusts x->ob_type->tp_mro".
A patch by mwh to check that user-defined mro's are reasonable enough.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_descr.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index 2ea8186..e954a0f 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -1635,6 +1635,37 @@ def altmro():
vereq(X.__mro__, (object, A, C, B, D, X))
vereq(X().f(), "A")
+ try:
+ class X(object):
+ class __metaclass__(type):
+ def mro(self):
+ return [self, dict, object]
+ except TypeError:
+ pass
+ else:
+ raise TestFailed, "devious mro() return not caught"
+
+ try:
+ class X(object):
+ class __metaclass__(type):
+ def mro(self):
+ return [1]
+ except TypeError:
+ pass
+ else:
+ raise TestFailed, "non-class mro() return not caught"
+
+ try:
+ class X(object):
+ class __metaclass__(type):
+ def mro(self):
+ return 1
+ except TypeError:
+ pass
+ else:
+ raise TestFailed, "non-sequence mro() return not caught"
+
+
def overloading():
if verbose: print "Testing operator overloading..."