From 8f6cbe150228f175b57b7a774d0a630febe72244 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 2 May 2006 17:36:09 +0000 Subject: [PATCH] Fix the formatting of KeyboardInterrupt -- a bad issubclass() call. --- Lib/test/test_traceback.py | 6 ++++++ Lib/traceback.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py index 22c04567a7..1b59f987aa 100644 --- a/Lib/test/test_traceback.py +++ b/Lib/test/test_traceback.py @@ -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) diff --git a/Lib/traceback.py b/Lib/traceback.py index 454eb1b7de..d900f52337 100644 --- a/Lib/traceback.py +++ b/Lib/traceback.py @@ -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 -- 2.40.0