Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1f9e601

Browse files
committed
Issue #20510: Confirm that the code attribute of the SystemExit
exception raised by sys.exit is None when no code is given. As suggested by Serhiy Storchaka.
1 parent e959776 commit 1f9e601

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

Lib/test/test_sys.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ def test_exit(self):
9191
self.assertRaises(TypeError, sys.exit, 42, 42)
9292

9393
# call without argument
94+
with self.assertRaises(SystemExit) as cm:
95+
sys.exit()
96+
self.assertIsNone(cm.exception.code)
97+
9498
rc, out, err = assert_python_ok('-c', 'import sys; sys.exit()')
9599
self.assertEqual(rc, 0)
96100
self.assertEqual(out, b'')

0 commit comments

Comments
 (0)