diff -r db7ec64aac39 Modules/signalmodule.c --- a/Modules/signalmodule.c Mon Jan 26 16:43:36 2015 +0100 +++ b/Modules/signalmodule.c Mon Jan 26 22:11:12 2015 +0200 @@ -1039,6 +1039,19 @@ Send a signal to a thread."); #endif /* #if defined(HAVE_PTHREAD_KILL) && defined(WITH_THREAD) */ +static PyObject * +signal_sig_const(PyObject *self, PyObject *args) +{ + PyErr_SetString(PyExc_TypeError, + "standard handler can't be called directly"); + return NULL; +} + +PyDoc_STRVAR(signal_SIG_DFL_doc, +"Standard handler used to refer to the system default handler."); + +PyDoc_STRVAR(signal_SIG_IGN_doc, +"Standard handler used to ignore the signal."); /* List of functions defined in the module */ static PyMethodDef signal_methods[] = { @@ -1087,6 +1100,8 @@ static PyMethodDef signal_methods[] = { {"sigtimedwait", (PyCFunction)signal_sigtimedwait, METH_VARARGS, signal_sigtimedwait_doc}, #endif + {"SIG_DFL", signal_sig_const, METH_VARARGS, signal_SIG_DFL_doc}, + {"SIG_IGN", signal_sig_const, METH_VARARGS, signal_SIG_IGN_doc}, {NULL, NULL} /* sentinel */ }; @@ -1106,8 +1121,6 @@ pause() -- wait until a signal arrives [ default_int_handler() -- default SIGINT handler\n\ \n\ signal constants:\n\ -SIG_DFL -- used to refer to the system default handler\n\ -SIG_IGN -- used to ignore the signal\n\ NSIG -- number of defined signals\n\ SIGINT, SIGTERM, etc. -- signal numbers\n\ \n\ @@ -1168,13 +1181,15 @@ PyInit__signal(void) /* Add some symbolic constants to the module */ d = PyModule_GetDict(m); - x = DefaultHandler = PyLong_FromVoidPtr((void *)SIG_DFL); - if (!x || PyDict_SetItemString(d, "SIG_DFL", x) < 0) + x = DefaultHandler = PyDict_GetItemString(d, "SIG_DFL"); + if (!x) goto finally; + Py_INCREF(DefaultHandler); - x = IgnoreHandler = PyLong_FromVoidPtr((void *)SIG_IGN); - if (!x || PyDict_SetItemString(d, "SIG_IGN", x) < 0) + x = IgnoreHandler = PyDict_GetItemString(d, "SIG_IGN"); + if (!x) goto finally; + Py_INCREF(IgnoreHandler); x = PyLong_FromLong((long)NSIG); if (!x || PyDict_SetItemString(d, "NSIG", x) < 0)