bpo-43146: fix None-handling in single-arg traceback.print_exception(None) (GH-24629)

(The previous commit fixed print_exception(None, None, None).)
This commit is contained in:
Irit Katriel 2021-02-23 17:43:04 +00:00 committed by GitHub
parent 26f18b8540
commit b798ab0693
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 1 deletions

View file

@ -234,6 +234,10 @@ class TracebackCases(unittest.TestCase):
def test_exception_is_None(self):
NONE_EXC_STRING = 'NoneType: None\n'
excfile = StringIO()
traceback.print_exception(None, file=excfile)
self.assertEqual(excfile.getvalue(), NONE_EXC_STRING)
excfile = StringIO()
traceback.print_exception(None, None, None, file=excfile)
self.assertEqual(excfile.getvalue(), NONE_EXC_STRING)
@ -243,6 +247,7 @@ class TracebackCases(unittest.TestCase):
self.assertEqual(excfile.getvalue(), NONE_EXC_STRING)
self.assertEqual(traceback.format_exc(None), NONE_EXC_STRING)
self.assertEqual(traceback.format_exception(None), [NONE_EXC_STRING])
self.assertEqual(
traceback.format_exception(None, None, None), [NONE_EXC_STRING])
self.assertEqual(