Message235412
In tracking down an obscure error we were seeing, we boiled it down to this test case for thread.interrupt_main():
import signal, threading, _thread, time
signal.signal(signal.SIGINT, signal.SIG_DFL) # or SIG_IGN
def thread_run():
_thread.interrupt_main()
t = threading.Thread(target=thread_run)
t.start()
time.sleep(10)
This fails with an error message "TypeError: 'int' object is not callable", and a traceback completely disconnected from the cause of the error, presumably because it's not coming from the usual Python stack.
The problem appears to be that interrupt_main sets (in the C code) Handlers[SIGINT].tripped, which is only expected to occur when the handler is a Python function. When PyErr_CheckSignals() runs, it tries to call Handlers[SIGINT].func as a Python function, but it's a Python integer, causing the error.
I think the fix for this is to check what Handlers[sig_num].func is, either in trip_signal() before setting Handlers[sig_num].tripped, or in PyErr_CheckSignals before calling it. I can work on a patch if desired, but I'm not brilliant at C. |
|
Date |
User |
Action |
Args |
2015-02-04 23:50:50 | takluyver | set | recipients:
+ takluyver, minrk |
2015-02-04 23:50:50 | takluyver | set | messageid: <1423093850.42.0.241477195496.issue23395@psf.upfronthosting.co.za> |
2015-02-04 23:50:50 | takluyver | link | issue23395 messages |
2015-02-04 23:50:49 | takluyver | create | |
|