From 6c502ba809ff662a5eebf8c6778dec6bd28918fb Mon Sep 17 00:00:00 2001 From: AN Long Date: Tue, 16 Jan 2024 16:32:39 +0800 Subject: [PATCH] gh-114101: Correct PyErr_Format arguments in _testcapi module (#114102) - use PyErr_SetString() iso. PyErr_Format() in parse_tuple_and_keywords() - fix misspelled format specifier in CHECK_SIGNNESS() macro --- Modules/_testcapi/getargs.c | 4 ++-- Modules/_testcapimodule.c | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Modules/_testcapi/getargs.c b/Modules/_testcapi/getargs.c index 33e8af7d7bb..0d61d8c8969 100644 --- a/Modules/_testcapi/getargs.c +++ b/Modules/_testcapi/getargs.c @@ -56,9 +56,9 @@ parse_tuple_and_keywords(PyObject *self, PyObject *args) keywords[i] = PyBytes_AS_STRING(o); } else { - PyErr_Format(PyExc_ValueError, + PyErr_SetString(PyExc_ValueError, "parse_tuple_and_keywords: " - "keywords must be str or bytes", i); + "keywords must be str or bytes"); goto exit; } } diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index a0b21b7efbd..6def680190b 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -112,12 +112,12 @@ test_sizeof_c_types(PyObject *self, PyObject *Py_UNUSED(ignored)) return (PyObject*)NULL; \ } #define IS_SIGNED(TYPE) (((TYPE)-1) < (TYPE)0) -#define CHECK_SIGNNESS(TYPE, SIGNED) \ - if (IS_SIGNED(TYPE) != SIGNED) { \ - PyErr_Format(get_testerror(self), \ - "%s signness is, instead of %i", \ - #TYPE, IS_SIGNED(TYPE), SIGNED); \ - return (PyObject*)NULL; \ +#define CHECK_SIGNNESS(TYPE, SIGNED) \ + if (IS_SIGNED(TYPE) != SIGNED) { \ + PyErr_Format(get_testerror(self), \ + "%s signness is %i, instead of %i", \ + #TYPE, IS_SIGNED(TYPE), SIGNED); \ + return (PyObject*)NULL; \ } /* integer types */