Skip to content

Commit 12ce58f

Browse files
committed
gh-156204: convert test helper to Argument Clinic
1 parent 170d3c9 commit 12ce58f

2 files changed

Lines changed: 46 additions & 10 deletions

File tree

‎Modules/_testcapi/clinic/exceptions.c.h‎

Lines changed: 32 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Modules/_testcapi/exceptions.c‎

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,23 @@ err_restore(PyObject *self, PyObject *args) {
5454
return NULL;
5555
}
5656

57+
/*[clinic input]
58+
_testcapi.err_givenexceptionmatches
59+
err: object
60+
exc: object
61+
/
62+
63+
Test PyErr_GivenExceptionMatches().
64+
[clinic start generated code]*/
65+
5766
static PyObject *
58-
err_givenexceptionmatches(PyObject *Py_UNUSED(module), PyObject *args)
67+
_testcapi_err_givenexceptionmatches_impl(PyObject *module, PyObject *err,
68+
PyObject *exc)
69+
/*[clinic end generated code: output=e40994ab6dd75001 input=7b8ef542df07575b]*/
5970
{
60-
PyObject *err, *exc;
61-
if (!PyArg_ParseTuple(args, "OO", &err, &exc)) {
62-
return NULL;
63-
}
6471
assert(!PyErr_Occurred());
6572
int res = PyErr_GivenExceptionMatches(err, exc);
66-
/* PyErr_GivenExceptionMatches() has no failure return value, but it can
67-
* set RecursionError on a deeply nested tuple; report that to the caller.
68-
*/
73+
/* The function has no failure return, but it can set RecursionError. */
6974
if (res == 0 && PyErr_Occurred()) {
7075
return NULL;
7176
}
@@ -562,7 +567,6 @@ static PyTypeObject PyRecursingInfinitelyError_Type = {
562567

563568
static PyMethodDef test_methods[] = {
564569
{"err_restore", err_restore, METH_VARARGS},
565-
{"err_givenexceptionmatches", err_givenexceptionmatches, METH_VARARGS},
566570
{"err_writeunraisable", err_writeunraisable, METH_VARARGS},
567571
{"err_formatunraisable", err_formatunraisable, METH_VARARGS},
568572
_TESTCAPI_ERR_SET_RAISED_METHODDEF
@@ -571,6 +575,7 @@ static PyMethodDef test_methods[] = {
571575
_TESTCAPI_MAKE_EXCEPTION_WITH_DOC_METHODDEF
572576
_TESTCAPI_EXC_SET_OBJECT_METHODDEF
573577
_TESTCAPI_EXC_SET_OBJECT_FETCH_METHODDEF
578+
_TESTCAPI_ERR_GIVENEXCEPTIONMATCHES_METHODDEF
574579
_TESTCAPI_ERR_SETSTRING_METHODDEF
575580
_TESTCAPI_ERR_SETFROMERRNOWITHFILENAME_METHODDEF
576581
_TESTCAPI_RAISE_EXCEPTION_METHODDEF

0 commit comments

Comments
 (0)