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.
This commit is contained in:
Zachary Ware 2014-02-19 10:44:47 -06:00
parent e95977621d
commit 1f9e601765
1 changed files with 4 additions and 0 deletions

View File

@ -91,6 +91,10 @@ class SysModuleTest(unittest.TestCase):
self.assertRaises(TypeError, sys.exit, 42, 42) self.assertRaises(TypeError, sys.exit, 42, 42)
# call without argument # call without argument
with self.assertRaises(SystemExit) as cm:
sys.exit()
self.assertIsNone(cm.exception.code)
rc, out, err = assert_python_ok('-c', 'import sys; sys.exit()') rc, out, err = assert_python_ok('-c', 'import sys; sys.exit()')
self.assertEqual(rc, 0) self.assertEqual(rc, 0)
self.assertEqual(out, b'') self.assertEqual(out, b'')