Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
gh-64631: Test exception messages in cloned Argument Clinic funcs
  • Loading branch information
erlend-aasland committed May 4, 2023
commit 4a4e328d343659b2e7edcbad7223460baa455674
7 changes: 7 additions & 0 deletions Lib/test/test_clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,13 @@ def test_gh_99240_double_free(self):
with self.assertRaisesRegex(TypeError, expected_error):
ac_tester.gh_99240_double_free('a', '\0b')

def test_cloned_func_exception_message(self):
incorrect_arg = -1 # f1() and f2() accept a single str
with self.assertRaisesRegex(TypeError, "clone_f1"):
ac_tester.clone_f1(incorrect_arg)
with self.assertRaisesRegex(TypeError, "clone_f2"):
ac_tester.clone_f2(incorrect_arg)


if __name__ == "__main__":
unittest.main()
29 changes: 29 additions & 0 deletions Modules/_testclinic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,33 @@ gh_99240_double_free_impl(PyObject *module, char *a, char *b)
}


/*[clinic input]
_testclinic.clone_f1 as clone_f1
path: str

[clinic start generated code]*/

static PyObject *
clone_f1_impl(PyObject *module, const char *path)
/*[clinic end generated code: output=8c30b5620ba86715 input=c956032414f389b4]*/
{
Py_RETURN_NONE;
}


/*[clinic input]
_testclinic.clone_f2 as clone_f2 = _testclinic.clone_f1

[clinic start generated code]*/

static PyObject *
clone_f2_impl(PyObject *module, const char *path)
/*[clinic end generated code: output=6aa1c39bec3f5d9b input=cf854c3ad41ddd85]*/
{
Py_RETURN_NONE;
}


static PyMethodDef tester_methods[] = {
TEST_EMPTY_FUNCTION_METHODDEF
OBJECTS_CONVERTER_METHODDEF
Expand Down Expand Up @@ -1168,6 +1195,8 @@ static PyMethodDef tester_methods[] = {
GH_32092_KW_PASS_METHODDEF
GH_99233_REFCOUNT_METHODDEF
GH_99240_DOUBLE_FREE_METHODDEF
CLONE_F1_METHODDEF
CLONE_F2_METHODDEF
{NULL, NULL}
};

Expand Down
134 changes: 133 additions & 1 deletion Modules/clinic/_testclinic.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.