Skip to content

Commit 534a98e

Browse files
committed
Fix format specifiers in error messages for watcher and size checks
1 parent 1fd66ea commit 534a98e

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
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: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -417,14 +417,14 @@ test_bswap(PyObject *self, PyObject *Py_UNUSED(args))
417417
uint16_t u16 = _Py_bswap16(UINT16_C(0x3412));
418418
if (u16 != UINT16_C(0x1234)) {
419419
PyErr_Format(PyExc_AssertionError,
420-
"_Py_bswap16(0x3412) returns %u", u16);
420+
"_Py_bswap16(0x3412) returns %d", u16);
421421
return NULL;
422422
}
423423

424424
uint32_t u32 = _Py_bswap32(UINT32_C(0x78563412));
425425
if (u32 != UINT32_C(0x12345678)) {
426426
PyErr_Format(PyExc_AssertionError,
427-
"_Py_bswap32(0x78563412) returns %lu", u32);
427+
"_Py_bswap32(0x78563412) returns %u", u32);
428428
return NULL;
429429
}
430430

@@ -711,7 +711,7 @@ check_bytes_find(const char *haystack0, const char *needle0,
711711
needle0, len_needle, offset);
712712
if (result_1 != expected) {
713713
PyErr_Format(PyExc_AssertionError,
714-
"Incorrect result_1: '%s' in '%s' (offset=%zd)",
714+
"Incorrect result_1: '%s' in '%s' (offset=%d)",
715715
needle0, haystack0, offset);
716716
return -1;
717717
}
@@ -735,7 +735,7 @@ check_bytes_find(const char *haystack0, const char *needle0,
735735
PyMem_Free(needle);
736736
if (result_2 != expected) {
737737
PyErr_Format(PyExc_AssertionError,
738-
"Incorrect result_2: '%s' in '%s' (offset=%zd)",
738+
"Incorrect result_2: '%s' in '%s' (offset=%d)",
739739
needle0, haystack0, offset);
740740
return -1;
741741
}
@@ -1158,7 +1158,7 @@ get_interp_settings(PyObject *self, PyObject *args)
11581158
}
11591159
else {
11601160
PyErr_Format(PyExc_NotImplementedError,
1161-
"%zd", interpid);
1161+
"%d", interpid);
11621162
return NULL;
11631163
}
11641164
assert(interp != NULL);

0 commit comments

Comments
 (0)