diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c --- a/Modules/signalmodule.c +++ b/Modules/signalmodule.c @@ -1317,6 +1317,8 @@ { int i; PyObject *f; + PyThreadState *tstate; + int postponed = 0; if (!is_tripped) return 0; @@ -1345,10 +1347,19 @@ if (!(f = (PyObject *)PyEval_GetFrame())) f = Py_None; + tstate = PyThreadState_GET(); + for (i = 1; i < NSIG; i++) { if (Handlers[i].tripped) { - PyObject *result = NULL; - PyObject *arglist = Py_BuildValue("(iO)", i, f); + PyObject *result; + PyObject *arglist; + if (tstate->c_traceobj != NULL && tstate->tracing && i != SIGINT) { + postponed = 1; + continue; + } + + result = NULL; + arglist = Py_BuildValue("(iO)", i, f); Handlers[i].tripped = 0; if (arglist) { @@ -1363,6 +1374,11 @@ } } + if (postponed && ! is_tripped) { + is_tripped = 1; + Py_AddPendingCall(checksignals_witharg, NULL); + } + return 0; }