Commit 8f6cbe15 authored by Guido van Rossum's avatar Guido van Rossum

Fix the formatting of KeyboardInterrupt -- a bad issubclass() call.

parent a883701d
......@@ -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)
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment