bpo-43146: fix regression in traceback.print_exception(None) (GH-24463)

This commit is contained in:
Irit Katriel 2021-02-23 14:58:47 +00:00 committed by GitHub
parent 7bb1cafa4e
commit 26f18b8540
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 1 deletions

View file

@ -232,6 +232,24 @@ class TracebackCases(unittest.TestCase):
output = traceback.format_exception_only(Exception("projector"))
self.assertEqual(output, ["Exception: projector\n"])
def test_exception_is_None(self):
NONE_EXC_STRING = 'NoneType: None\n'
excfile = StringIO()
traceback.print_exception(None, None, None, file=excfile)
self.assertEqual(excfile.getvalue(), NONE_EXC_STRING)
excfile = StringIO()
traceback.print_exc(None, file=excfile)
self.assertEqual(excfile.getvalue(), NONE_EXC_STRING)
self.assertEqual(traceback.format_exc(None), NONE_EXC_STRING)
self.assertEqual(
traceback.format_exception(None, None, None), [NONE_EXC_STRING])
self.assertEqual(
traceback.format_exception_only(None), [NONE_EXC_STRING])
self.assertEqual(
traceback.format_exception_only(None, None), [NONE_EXC_STRING])
class TracebackFormatTests(unittest.TestCase):