summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-07-21 10:30:22 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-07-21 10:30:22 (GMT)
commit56e8c29a4e5f5907e2e170e23d9a57e564401a75 (patch)
tree9d5e7dd32897d3380b85093d456f464d3ad7b577 /Modules
parent569a7fa13a1a69b070e9aff9a5fdc065960e4db1 (diff)
downloadcpython-56e8c29a4e5f5907e2e170e23d9a57e564401a75.zip
cpython-56e8c29a4e5f5907e2e170e23d9a57e564401a75.tar.gz
cpython-56e8c29a4e5f5907e2e170e23d9a57e564401a75.tar.bz2
Issue #22018: Add _testcapi.raise_signal()
- Use _testcapi.raise_signal() in test_signal - close also os.pipe() file descriptors in some test_signal tests where they were not closed properly - Remove faulthandler._sigill() and faulthandler._sigbus(): reuse _testcapi.raise_signal() in test_faulthandler
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_testcapimodule.c21
-rw-r--r--Modules/faulthandler.c26
2 files changed, 21 insertions, 26 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 05a27d6..ebbf88f 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -11,6 +11,7 @@
#include <float.h>
#include "structmember.h"
#include "datetime.h"
+#include <signal.h>
#ifdef WITH_THREAD
#include "pythread.h"
@@ -3063,6 +3064,24 @@ exit:
}
#endif /* WITH_THREAD */
+static PyObject*
+test_raise_signal(PyObject* self, PyObject *args)
+{
+ int signum, err;
+
+ if (PyArg_ParseTuple(args, "i:raise_signal", &signum) < 0)
+ return NULL;
+
+ err = raise(signum);
+ if (err)
+ return PyErr_SetFromErrno(PyExc_OSError);
+
+ if (PyErr_CheckSignals() < 0)
+ return NULL;
+
+ Py_RETURN_NONE;
+}
+
static PyMethodDef TestMethods[] = {
{"raise_exception", raise_exception, METH_VARARGS},
@@ -3198,6 +3217,8 @@ static PyMethodDef TestMethods[] = {
{"docstring_with_signature_with_defaults",
(PyCFunction)test_with_docstring, METH_NOARGS,
docstring_with_signature_with_defaults},
+ {"raise_signal",
+ (PyCFunction)test_raise_signal, METH_VARARGS},
#ifdef WITH_THREAD
{"call_in_temporary_c_thread", call_in_temporary_c_thread, METH_O,
PyDoc_STR("set_error_class(error_class) -> None")},
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c
index 6a145dc..97963ef 100644
--- a/Modules/faulthandler.c
+++ b/Modules/faulthandler.c
@@ -874,24 +874,6 @@ faulthandler_sigabrt(PyObject *self, PyObject *args)
Py_RETURN_NONE;
}
-#ifdef SIGBUS
-static PyObject *
-faulthandler_sigbus(PyObject *self, PyObject *args)
-{
- raise(SIGBUS);
- Py_RETURN_NONE;
-}
-#endif
-
-#ifdef SIGILL
-static PyObject *
-faulthandler_sigill(PyObject *self, PyObject *args)
-{
- raise(SIGILL);
- Py_RETURN_NONE;
-}
-#endif
-
static PyObject *
faulthandler_fatal_error_py(PyObject *self, PyObject *args)
{
@@ -1012,14 +994,6 @@ static PyMethodDef module_methods[] = {
PyDoc_STR("_sigabrt(): raise a SIGABRT signal")},
{"_sigfpe", (PyCFunction)faulthandler_sigfpe, METH_NOARGS,
PyDoc_STR("_sigfpe(): raise a SIGFPE signal")},
-#ifdef SIGBUS
- {"_sigbus", (PyCFunction)faulthandler_sigbus, METH_NOARGS,
- PyDoc_STR("_sigbus(): raise a SIGBUS signal")},
-#endif
-#ifdef SIGILL
- {"_sigill", (PyCFunction)faulthandler_sigill, METH_NOARGS,
- PyDoc_STR("_sigill(): raise a SIGILL signal")},
-#endif
{"_fatal_error", faulthandler_fatal_error_py, METH_VARARGS,
PyDoc_STR("_fatal_error(message): call Py_FatalError(message)")},
#if defined(HAVE_SIGALTSTACK) && defined(HAVE_SIGACTION)