diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2008-08-26 22:40:48 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2008-08-26 22:40:48 (GMT) |
commit | ec569b794737be248671d0dfac11b664fc930eef (patch) | |
tree | 76d3b98a51063f9f922a15cbe36ca58a7f0892da /Lib/test/test_exceptions.py | |
parent | e2dffc0aeb6e03d8e6512a13cb3fe05562f7c655 (diff) | |
download | cpython-ec569b794737be248671d0dfac11b664fc930eef.zip cpython-ec569b794737be248671d0dfac11b664fc930eef.tar.gz cpython-ec569b794737be248671d0dfac11b664fc930eef.tar.bz2 |
Issue #2534: speed up isinstance() and issubclass() by 50-70%, so as to
match Python 2.5 speed despite the __instancecheck__ / __subclasscheck__
mechanism. In the process, fix a bug where isinstance() and issubclass(),
when given a tuple of classes as second argument, were looking up
__instancecheck__ / __subclasscheck__ on the tuple rather than on each
type object.
Reviewed by Benjamin Peterson and Raymond Hettinger.
Diffstat (limited to 'Lib/test/test_exceptions.py')
-rw-r--r-- | Lib/test/test_exceptions.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index c7de97c..b671cbc 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -582,12 +582,18 @@ class ExceptionTests(unittest.TestCase): except KeyError: pass except: - self.fail("Should have raised TypeError") + self.fail("Should have raised KeyError") else: - self.fail("Should have raised TypeError") - self.assertEqual(stderr.getvalue(), - "Exception ValueError: ValueError() " - "in <class 'KeyError'> ignored\n") + self.fail("Should have raised KeyError") + + def g(): + try: + return g() + except RuntimeError: + return sys.exc_info() + e, v, tb = g() + self.assert_(isinstance(v, RuntimeError), type(v)) + self.assert_("maximum recursion depth exceeded" in str(v), str(v)) def test_MemoryError(self): |