mirror of
https://github.com/python/cpython.git
synced 2025-11-01 10:45:30 +00:00
gh-108082: Add PyErr_FormatUnraisable() function (GH-111086)
This commit is contained in:
parent
453e96e302
commit
f6a02327b5
7 changed files with 142 additions and 8 deletions
|
|
@ -319,6 +319,30 @@ err_writeunraisable(PyObject *Py_UNUSED(module), PyObject *args)
|
|||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
err_formatunraisable(PyObject *Py_UNUSED(module), PyObject *args)
|
||||
{
|
||||
PyObject *exc;
|
||||
const char *fmt;
|
||||
Py_ssize_t fmtlen;
|
||||
PyObject *objs[10] = {NULL};
|
||||
|
||||
if (!PyArg_ParseTuple(args, "Oz#|OOOOOOOOOO", &exc, &fmt, &fmtlen,
|
||||
&objs[0], &objs[1], &objs[2], &objs[3], &objs[4],
|
||||
&objs[5], &objs[6], &objs[7], &objs[8], &objs[9]))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
NULLABLE(exc);
|
||||
if (exc) {
|
||||
PyErr_SetRaisedException(Py_NewRef(exc));
|
||||
}
|
||||
PyErr_FormatUnraisable(fmt,
|
||||
objs[0], objs[1], objs[2], objs[3], objs[4],
|
||||
objs[5], objs[6], objs[7], objs[8], objs[9]);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
/*[clinic input]
|
||||
_testcapi.unstable_exc_prep_reraise_star
|
||||
orig: object
|
||||
|
|
@ -364,6 +388,7 @@ static PyTypeObject PyRecursingInfinitelyError_Type = {
|
|||
static PyMethodDef test_methods[] = {
|
||||
{"err_restore", err_restore, METH_VARARGS},
|
||||
{"err_writeunraisable", err_writeunraisable, METH_VARARGS},
|
||||
{"err_formatunraisable", err_formatunraisable, METH_VARARGS},
|
||||
_TESTCAPI_ERR_SET_RAISED_METHODDEF
|
||||
_TESTCAPI_EXCEPTION_PRINT_METHODDEF
|
||||
_TESTCAPI_FATAL_ERROR_METHODDEF
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue