mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
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
This commit is contained in:
parent
569a7fa13a
commit
56e8c29a4e
4 changed files with 85 additions and 53 deletions
|
@ -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")},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue