bpo-41602: raise SIGINT exit code on KeyboardInterrupt from pymain_run_module (#21956)

Closes bpo issue 41602
This commit is contained in:
Thomas Grainger 2020-09-22 16:53:03 +01:00 committed by GitHub
parent ea0711a9f9
commit a68a2ad19c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 94 additions and 9 deletions

View file

@ -287,7 +287,11 @@ pymain_run_module(const wchar_t *modname, int set_argv0)
Py_DECREF(module);
return pymain_exit_err_print();
}
_Py_UnhandledKeyboardInterrupt = 0;
result = PyObject_Call(runmodule, runargs, NULL);
if (!result && PyErr_Occurred() == PyExc_KeyboardInterrupt) {
_Py_UnhandledKeyboardInterrupt = 1;
}
Py_DECREF(runpy);
Py_DECREF(runmodule);
Py_DECREF(module);