diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_traceback.py | 4 | ||||
-rw-r--r-- | Lib/traceback.py | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py index b3c5a50..b42dbc4 100644 --- a/Lib/test/test_traceback.py +++ b/Lib/test/test_traceback.py @@ -149,6 +149,10 @@ def test(): str_value = '<unprintable %s object>' % X.__name__ self.assertEqual(err[0], X.__name__ + ': ' + str_value + '\n') + def test_without_exception(self): + err = traceback.format_exception_only(None, None) + self.assertEqual(err, ['None\n']) + def test_main(): run_unittest(TracebackCases) diff --git a/Lib/traceback.py b/Lib/traceback.py index 75e1fcf..31b8255 100644 --- a/Lib/traceback.py +++ b/Lib/traceback.py @@ -170,7 +170,7 @@ def format_exception_only(etype, value): # would throw another exception and mask the original problem. if (isinstance(etype, BaseException) or isinstance(etype, types.InstanceType) or - type(etype) is str): + etype is None or type(etype) is str): return [_format_final_exc_line(etype, value)] stype = etype.__name__ |