diff options
author | Vladimir Matveev <v2matveev@outlook.com> | 2019-01-08 09:58:25 (GMT) |
---|---|---|
committer | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-01-08 09:58:25 (GMT) |
commit | c24c6c2c9357da99961bf257078240529181daf3 (patch) | |
tree | 552b9c627f21770d971d26f0d7d38e8a1b58ea02 /Modules/clinic/signalmodule.c.h | |
parent | e61cc481e02b758c8d8289163102c236d0658a55 (diff) | |
download | cpython-c24c6c2c9357da99961bf257078240529181daf3.zip cpython-c24c6c2c9357da99961bf257078240529181daf3.tar.gz cpython-c24c6c2c9357da99961bf257078240529181daf3.tar.bz2 |
bpo-35568: add 'raise_signal' function (GH-11335)
As in title, expose C `raise` function as `raise_function` in `signal` module. Also drop existing `raise_signal` in `_testcapi` module and replace all usages with new function.
https://bugs.python.org/issue35568
Diffstat (limited to 'Modules/clinic/signalmodule.c.h')
-rw-r--r-- | Modules/clinic/signalmodule.c.h | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/Modules/clinic/signalmodule.c.h b/Modules/clinic/signalmodule.c.h index 6745f45..f374226 100644 --- a/Modules/clinic/signalmodule.c.h +++ b/Modules/clinic/signalmodule.c.h @@ -66,6 +66,39 @@ signal_pause(PyObject *module, PyObject *Py_UNUSED(ignored)) #endif /* defined(HAVE_PAUSE) */ +PyDoc_STRVAR(signal_raise_signal__doc__, +"raise_signal($module, signalnum, /)\n" +"--\n" +"\n" +"Send a signal to the executing process."); + +#define SIGNAL_RAISE_SIGNAL_METHODDEF \ + {"raise_signal", (PyCFunction)signal_raise_signal, METH_O, signal_raise_signal__doc__}, + +static PyObject * +signal_raise_signal_impl(PyObject *module, int signalnum); + +static PyObject * +signal_raise_signal(PyObject *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int signalnum; + + if (PyFloat_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "integer argument expected, got float" ); + goto exit; + } + signalnum = _PyLong_AsInt(arg); + if (signalnum == -1 && PyErr_Occurred()) { + goto exit; + } + return_value = signal_raise_signal_impl(module, signalnum); + +exit: + return return_value; +} + PyDoc_STRVAR(signal_signal__doc__, "signal($module, signalnum, handler, /)\n" "--\n" @@ -558,4 +591,4 @@ exit: #ifndef SIGNAL_PTHREAD_KILL_METHODDEF #define SIGNAL_PTHREAD_KILL_METHODDEF #endif /* !defined(SIGNAL_PTHREAD_KILL_METHODDEF) */ -/*[clinic end generated code: output=4ed8c36860f9f577 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=365db4e807c26d4e input=a9049054013a1b77]*/ |