[Python-checkins] r45858 - in python/trunk/Lib: test/test_traceback.py traceback.py

guido.van.rossum python-checkins at python.org
Tue May 2 19:36:10 CEST 2006


Author: guido.van.rossum
Date: Tue May  2 19:36:09 2006
New Revision: 45858

Modified:
   python/trunk/Lib/test/test_traceback.py
   python/trunk/Lib/traceback.py
Log:
Fix the formatting of KeyboardInterrupt -- a bad issubclass() call.


Modified: python/trunk/Lib/test/test_traceback.py
==============================================================================
--- python/trunk/Lib/test/test_traceback.py	(original)
+++ python/trunk/Lib/test/test_traceback.py	Tue May  2 19:36:09 2006
@@ -103,6 +103,12 @@
             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)
 

Modified: python/trunk/Lib/traceback.py
==============================================================================
--- python/trunk/Lib/traceback.py	(original)
+++ python/trunk/Lib/traceback.py	Tue May  2 19:36:09 2006
@@ -158,7 +158,7 @@
     """
     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


More information about the Python-checkins mailing list