Skip to content

Commit 6c502ba

Browse files
authored
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
1 parent 8fd287b commit 6c502ba

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Modules/_testcapi/getargs.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ parse_tuple_and_keywords(PyObject *self, PyObject *args)
5656
keywords[i] = PyBytes_AS_STRING(o);
5757
}
5858
else {
59-
PyErr_Format(PyExc_ValueError,
59+
PyErr_SetString(PyExc_ValueError,
6060
"parse_tuple_and_keywords: "
61-
"keywords must be str or bytes", i);
61+
"keywords must be str or bytes");
6262
goto exit;
6363
}
6464
}

Modules/_testcapimodule.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,12 @@ test_sizeof_c_types(PyObject *self, PyObject *Py_UNUSED(ignored))
112112
return (PyObject*)NULL; \
113113
}
114114
#define IS_SIGNED(TYPE) (((TYPE)-1) < (TYPE)0)
115-
#define CHECK_SIGNNESS(TYPE, SIGNED) \
116-
if (IS_SIGNED(TYPE) != SIGNED) { \
117-
PyErr_Format(get_testerror(self), \
118-
"%s signness is, instead of %i", \
119-
#TYPE, IS_SIGNED(TYPE), SIGNED); \
120-
return (PyObject*)NULL; \
115+
#define CHECK_SIGNNESS(TYPE, SIGNED) \
116+
if (IS_SIGNED(TYPE) != SIGNED) { \
117+
PyErr_Format(get_testerror(self), \
118+
"%s signness is %i, instead of %i", \
119+
#TYPE, IS_SIGNED(TYPE), SIGNED); \
120+
return (PyObject*)NULL; \
121121
}
122122

123123
/* integer types */

0 commit comments

Comments
 (0)