summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-05-24 02:22:38 -0700
committerGitHub <noreply@github.com>2019-05-24 02:22:38 -0700
commit310f414bbd4d6ed1d8813f724c91ce9b4129c0ba (patch)
treebca2f14b6b451d2300e1a5b5e87785eb83f8cbcc /Modules
parenta3488e5902f5c26e5cc289aec2518e7b5058e5d1 (diff)
downloadcpython-git-310f414bbd4d6ed1d8813f724c91ce9b4129c0ba.tar.gz
bpo-23395: Fix PyErr_SetInterrupt if the SIGINT signal is ignored or not handled (GH-7778)
``_thread.interrupt_main()`` now avoids setting the Python error status if the ``SIGINT`` signal is ignored or not handled by Python. (cherry picked from commit 608876b6b1eb59538e6c29671a733033fb8b5be7) Co-authored-by: Matěj Cepl <mcepl@cepl.eu>
Diffstat (limited to 'Modules')
-rw-r--r--Modules/signalmodule.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index e70c6fc396..a0722b731c 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -1562,13 +1562,18 @@ PyErr_CheckSignals(void)
}
-/* Replacements for intrcheck.c functionality
- * Declared in pyerrors.h
- */
+/* Simulate the effect of a signal.SIGINT signal arriving. The next time
+ PyErr_CheckSignals is called, the Python SIGINT signal handler will be
+ raised.
+
+ Missing signal handler for the SIGINT signal is silently ignored. */
void
PyErr_SetInterrupt(void)
{
- trip_signal(SIGINT);
+ if ((Handlers[SIGINT].func != IgnoreHandler) &&
+ (Handlers[SIGINT].func != DefaultHandler)) {
+ trip_signal(SIGINT);
+ }
}
void