diff -r 51e7c9b54f56 Lib/test/test_sys.py --- a/Lib/test/test_sys.py Tue Jan 31 13:56:50 2017 +0100 +++ b/Lib/test/test_sys.py Wed Feb 01 18:14:08 2017 +0000 @@ -164,6 +164,17 @@ self.assertEqual(out, b'') self.assertEqual(err, b'') + # test that the exit machinery handles long exit codes + rc, out, err = assert_python_failure('-c', 'raise SystemExit(47L)') + self.assertEqual(rc, 47) + self.assertEqual(out, b'') + self.assertEqual(err, b'') + + rc, out, err = assert_python_ok('-c', 'raise SystemExit(0L)') + self.assertEqual(rc, 0) + self.assertEqual(out, b'') + self.assertEqual(err, b'') + def check_exit_message(code, expected, **env_vars): rc, out, err = assert_python_failure('-c', code, **env_vars) self.assertEqual(rc, 1) diff -r 51e7c9b54f56 Misc/NEWS --- a/Misc/NEWS Tue Jan 31 13:56:50 2017 +0100 +++ b/Misc/NEWS Wed Feb 01 18:14:08 2017 +0000 @@ -10,6 +10,9 @@ Core and Builtins ----------------- +- Issue #14376: Allow sys.exit to accept longs as well as ints. Patch + by Gareth Rees. + - Issue #29145: Fix overflow checks in string, bytearray and unicode. Patch by jan matejek and Xiang Zhang. diff -r 51e7c9b54f56 Python/pythonrun.c --- a/Python/pythonrun.c Tue Jan 31 13:56:50 2017 +0100 +++ b/Python/pythonrun.c Wed Feb 01 18:14:08 2017 +0000 @@ -1127,7 +1127,7 @@ /* If we failed to dig out the 'code' attribute, just let the else clause below print the error. */ } - if (PyInt_Check(value)) + if (PyInt_Check(value) || PyLong_Check(value)) exitcode = (int)PyInt_AsLong(value); else { PyObject *sys_stderr = PySys_GetObject("stderr");

AltStyle によって変換されたページ (->オリジナル) /