mirror of
https://github.com/python/cpython.git
synced 2025-09-03 15:31:08 +00:00
bpo-43146: fix regression in traceback.print_exception(None) (GH-24463)
This commit is contained in:
parent
7bb1cafa4e
commit
26f18b8540
3 changed files with 22 additions and 1 deletions
|
@ -232,6 +232,24 @@ class TracebackCases(unittest.TestCase):
|
||||||
output = traceback.format_exception_only(Exception("projector"))
|
output = traceback.format_exception_only(Exception("projector"))
|
||||||
self.assertEqual(output, ["Exception: projector\n"])
|
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):
|
class TracebackFormatTests(unittest.TestCase):
|
||||||
|
|
||||||
|
|
|
@ -528,7 +528,9 @@ class TracebackException:
|
||||||
cause = None
|
cause = None
|
||||||
|
|
||||||
if compact:
|
if compact:
|
||||||
need_context = cause is None and not e.__suppress_context__
|
need_context = (cause is None and
|
||||||
|
e is not None and
|
||||||
|
not e.__suppress_context__)
|
||||||
else:
|
else:
|
||||||
need_context = True
|
need_context = True
|
||||||
if (e and e.__context__ is not None
|
if (e and e.__context__ is not None
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Fix recent regression in None argument handling in :mod:`~traceback` module functions.
|
Loading…
Add table
Add a link
Reference in a new issue