From a8827f0ef462cb39bd643c07910bb06c0678b6f6 2015-02-05 19:11:40 From: Thomas Kluyver Date: 2015-02-05 19:11:40 Subject: [PATCH] Merge pull request #7688 from minrk/callable-interrupt check if SIGINT handler is callable before triggering it --- diff --git a/IPython/kernel/zmq/parentpoller.py b/IPython/kernel/zmq/parentpoller.py index b745b02..d623f9d 100644 --- a/IPython/kernel/zmq/parentpoller.py +++ b/IPython/kernel/zmq/parentpoller.py @@ -1,10 +1,13 @@ -# Standard library imports. +# Copyright (c) IPython Development Team. +# Distributed under the terms of the Modified BSD License. + try: import ctypes except: ctypes = None import os import platform +import signal import time try: from _thread import interrupt_main # Py 3 @@ -129,7 +132,10 @@ class ParentPollerWindows(Thread): handle = handles[result - WAIT_OBJECT_0] if handle == self.interrupt_handle: - interrupt_main() + # check if signal handler is callable + # to avoid 'int not callable' error (Python issue #23395) + if callable(signal.getsignal(signal.SIGINT)): + interrupt_main() elif handle == self.parent_handle: os._exit(1)