diff -r aed29f86bfdc Lib/test/test_sys.py --- a/Lib/test/test_sys.py Mon Feb 03 22:30:22 2014 +0200 +++ b/Lib/test/test_sys.py Tue Feb 04 15:30:19 2014 +0000 @@ -178,6 +178,11 @@ "raise SystemExit(47)"]) self.assertEqual(rc, 47) + # test that the exit machinery handles long exit codes + rc = subprocess.call([sys.executable, "-c", + "import sys; sys.exit(127L)"]) + self.assertEqual(rc, 127L) + def check_exit_message(code, expected, env=None): process = subprocess.Popen([sys.executable, "-c", code], stderr=subprocess.PIPE, env=env) diff -r aed29f86bfdc Python/pythonrun.c --- a/Python/pythonrun.c Mon Feb 03 22:30:22 2014 +0200 +++ b/Python/pythonrun.c Tue Feb 04 15:30:19 2014 +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");