summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_traceback.py
diff options
context:
space:
mode:
authorIrit Katriel <iritkatriel@yahoo.com>2021-02-23 14:58:47 (GMT)
committerGitHub <noreply@github.com>2021-02-23 14:58:47 (GMT)
commit26f18b8540b49d592af66361f8df1a03953d1768 (patch)
treeb66c33940549691dfb3d35d560e20ce79dc8cb96 /Lib/test/test_traceback.py
parent7bb1cafa4e3d648669212ea4c6d11d6eafc6da23 (diff)
downloadcpython-26f18b8540b49d592af66361f8df1a03953d1768.zip
cpython-26f18b8540b49d592af66361f8df1a03953d1768.tar.gz
cpython-26f18b8540b49d592af66361f8df1a03953d1768.tar.bz2
bpo-43146: fix regression in traceback.print_exception(None) (GH-24463)
Diffstat (limited to 'Lib/test/test_traceback.py')
-rw-r--r--Lib/test/test_traceback.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index 33bdda0..2261ea9 100644
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -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):