]> granicus.if.org Git - python/commitdiff
Fix the formatting of KeyboardInterrupt -- a bad issubclass() call.
authorGuido van Rossum <guido@python.org>
Tue, 2 May 2006 17:36:09 +0000 (17:36 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 2 May 2006 17:36:09 +0000 (17:36 +0000)
Lib/test/test_traceback.py
Lib/traceback.py

index 22c04567a7232f2fa1901e14d0cabf150a901517..1b59f987aa2189600439c0276fd45936d9a964c2 100644 (file)
@@ -103,6 +103,12 @@ def test():
             import sys
             sys.exc_traceback.__members__
 
+    def test_base_exception(self):
+        # Test that exceptions derived from BaseException are formatted right
+        e = KeyboardInterrupt()
+        lst = traceback.format_exception_only(e.__class__, e)
+        self.assertEqual(lst, ['KeyboardInterrupt\n'])
+
 def test_main():
     run_unittest(TracebackCases)
 
index 454eb1b7de6400ad7f8fe5fc57f84180f4e4b0d8..d900f52337aa78f6879d7f3c7d7a8d71aa11d326 100644 (file)
@@ -158,7 +158,7 @@ def format_exception_only(etype, value):
     """
     list = []
     if (type(etype) == types.ClassType
-        or (isinstance(etype, type) and issubclass(etype, Exception))):
+        or (isinstance(etype, type) and issubclass(etype, BaseException))):
         stype = etype.__name__
     else:
         stype = etype