]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-114101: Correct PyErr_Format arguments in _testcapi module (#114102)
authorAN Long <aisk@users.noreply.github.com>
Tue, 16 Jan 2024 08:32:39 +0000 (16:32 +0800)
committerGitHub <noreply@github.com>
Tue, 16 Jan 2024 08:32:39 +0000 (09:32 +0100)
- use PyErr_SetString() iso. PyErr_Format() in parse_tuple_and_keywords()
- fix misspelled format specifier in CHECK_SIGNNESS() macro

Modules/_testcapi/getargs.c
Modules/_testcapimodule.c

index 33e8af7d7bbb390a5f49841a184d298dfd0d8325..0d61d8c8969f8273c9f14a17ef4aac040d2d121a 100644 (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;
         }
     }
index a0b21b7efbd9716da75d05c5db10c6910970586c..6def680190b1a637eabd3ef491ac6bda5baf2134 100644 (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 */