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
This commit is contained in:
AN Long 2024-01-16 16:32:39 +08:00 committed by GitHub
parent 8fd287b18f
commit 6c502ba809
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View File

@ -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;
}
}

View File

@ -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 */