summaryrefslogtreecommitdiffstats
path: root/Modules/main.c
diff options
context:
space:
mode:
authorThomas Grainger <tagrain@gmail.com>2020-09-22 15:53:03 (GMT)
committerGitHub <noreply@github.com>2020-09-22 15:53:03 (GMT)
commita68a2ad19c891faa891904b3da537911cc77df21 (patch)
tree46fa0cc9d282a07bdfb1f1bad89504976dee2a9c /Modules/main.c
parentea0711a9f9f207d6d4ca037d90de6ec60db131b0 (diff)
downloadcpython-a68a2ad19c891faa891904b3da537911cc77df21.zip
cpython-a68a2ad19c891faa891904b3da537911cc77df21.tar.gz
cpython-a68a2ad19c891faa891904b3da537911cc77df21.tar.bz2
bpo-41602: raise SIGINT exit code on KeyboardInterrupt from pymain_run_module (#21956)
Closes bpo issue 41602
Diffstat (limited to 'Modules/main.c')
-rw-r--r--Modules/main.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Modules/main.c b/Modules/main.c
index 4a76f44..2cc891f 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -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);