Skip to content

Commit 985a482

Browse files
sunmy2019miss-islington
authored andcommitted
gh-146615: Fix format specifiers in test cextensions (GH-146618)
(cherry picked from commit b705553) Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
1 parent 99f333d commit 985a482

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

Modules/_testcapi/watchers.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ add_code_watcher(PyObject *self, PyObject *which_watcher)
364364
watcher_id = PyCode_AddWatcher(error_code_event_handler);
365365
}
366366
else {
367-
PyErr_Format(PyExc_ValueError, "invalid watcher %d", which_l);
367+
PyErr_Format(PyExc_ValueError, "invalid watcher %ld", which_l);
368368
return NULL;
369369
}
370370
if (watcher_id < 0) {
@@ -673,7 +673,7 @@ add_context_watcher(PyObject *self, PyObject *which_watcher)
673673
assert(PyLong_Check(which_watcher));
674674
long which_l = PyLong_AsLong(which_watcher);
675675
if (which_l < 0 || which_l >= (long)Py_ARRAY_LENGTH(callbacks)) {
676-
PyErr_Format(PyExc_ValueError, "invalid watcher %d", which_l);
676+
PyErr_Format(PyExc_ValueError, "invalid watcher %ld", which_l);
677677
return NULL;
678678
}
679679
int watcher_id = PyContext_AddWatcher(callbacks[which_l]);

Modules/_testcapimodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ test_sizeof_c_types(PyObject *self, PyObject *Py_UNUSED(ignored))
116116
do { \
117117
if (EXPECTED != sizeof(TYPE)) { \
118118
PyErr_Format(get_testerror(self), \
119-
"sizeof(%s) = %u instead of %u", \
120-
#TYPE, sizeof(TYPE), EXPECTED); \
119+
"sizeof(%s) = %zu instead of %u", \
120+
#TYPE, sizeof(TYPE), (unsigned)(EXPECTED)); \
121121
return (PyObject*)NULL; \
122122
} \
123123
} while (0)

Modules/_testinternalcapi.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,14 @@ test_bswap(PyObject *self, PyObject *Py_UNUSED(args))
144144
uint16_t u16 = _Py_bswap16(UINT16_C(0x3412));
145145
if (u16 != UINT16_C(0x1234)) {
146146
PyErr_Format(PyExc_AssertionError,
147-
"_Py_bswap16(0x3412) returns %u", u16);
147+
"_Py_bswap16(0x3412) returns %d", u16);
148148
return NULL;
149149
}
150150

151151
uint32_t u32 = _Py_bswap32(UINT32_C(0x78563412));
152152
if (u32 != UINT32_C(0x12345678)) {
153153
PyErr_Format(PyExc_AssertionError,
154-
"_Py_bswap32(0x78563412) returns %lu", u32);
154+
"_Py_bswap32(0x78563412) returns %u", u32);
155155
return NULL;
156156
}
157157

@@ -430,7 +430,7 @@ test_edit_cost(PyObject *self, PyObject *Py_UNUSED(args))
430430

431431
static int
432432
check_bytes_find(const char *haystack0, const char *needle0,
433-
int offset, Py_ssize_t expected)
433+
Py_ssize_t offset, Py_ssize_t expected)
434434
{
435435
Py_ssize_t len_haystack = strlen(haystack0);
436436
Py_ssize_t len_needle = strlen(needle0);
@@ -848,7 +848,7 @@ get_interp_settings(PyObject *self, PyObject *args)
848848
}
849849
else {
850850
PyErr_Format(PyExc_NotImplementedError,
851-
"%zd", interpid);
851+
"%d", interpid);
852852
return NULL;
853853
}
854854
assert(interp != NULL);

0 commit comments

Comments
 (0)