Skip to content

Commit dcb260e

Browse files
authored
gh-146615: Fix format specifiers in Python/ directory (GH-146619)
1 parent b705553 commit dcb260e

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

Python/bltinmodule.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,7 +1607,7 @@ map_next(PyObject *self)
16071607
// ValueError: map() argument 3 is shorter than arguments 1-2
16081608
const char* plural = i == 1 ? " " : "s 1-";
16091609
PyErr_Format(PyExc_ValueError,
1610-
"map() argument %d is shorter than argument%s%d",
1610+
"map() argument %zd is shorter than argument%s%zd",
16111611
i + 1, plural, i);
16121612
goto exit_no_result;
16131613
}
@@ -1618,7 +1618,7 @@ map_next(PyObject *self)
16181618
Py_DECREF(val);
16191619
const char* plural = i == 1 ? " " : "s 1-";
16201620
PyErr_Format(PyExc_ValueError,
1621-
"map() argument %d is longer than argument%s%d",
1621+
"map() argument %zd is longer than argument%s%zd",
16221622
i + 1, plural, i);
16231623
goto exit_no_result;
16241624
}
@@ -3307,7 +3307,7 @@ zip_next(PyObject *self)
33073307
// ValueError: zip() argument 3 is shorter than arguments 1-2
33083308
const char* plural = i == 1 ? " " : "s 1-";
33093309
return PyErr_Format(PyExc_ValueError,
3310-
"zip() argument %d is shorter than argument%s%d",
3310+
"zip() argument %zd is shorter than argument%s%zd",
33113311
i + 1, plural, i);
33123312
}
33133313
for (i = 1; i < tuplesize; i++) {
@@ -3317,7 +3317,7 @@ zip_next(PyObject *self)
33173317
Py_DECREF(item);
33183318
const char* plural = i == 1 ? " " : "s 1-";
33193319
return PyErr_Format(PyExc_ValueError,
3320-
"zip() argument %d is longer than argument%s%d",
3320+
"zip() argument %zd is longer than argument%s%zd",
33213321
i + 1, plural, i);
33223322
}
33233323
if (PyErr_Occurred()) {

Python/ceval.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ _PyEval_MatchClass(PyThreadState *tstate, PyObject *subject, PyObject *type,
602602
if (allowed < nargs) {
603603
const char *plural = (allowed == 1) ? "" : "s";
604604
_PyErr_Format(tstate, PyExc_TypeError,
605-
"%s() accepts %d positional sub-pattern%s (%d given)",
605+
"%s() accepts %zd positional sub-pattern%s (%zd given)",
606606
((PyTypeObject*)type)->tp_name,
607607
allowed, plural, nargs);
608608
goto fail;
@@ -1555,7 +1555,7 @@ format_missing(PyThreadState *tstate, const char *kind,
15551555
if (name_str == NULL)
15561556
return;
15571557
_PyErr_Format(tstate, PyExc_TypeError,
1558-
"%U() missing %i required %s argument%s: %U",
1558+
"%U() missing %zd required %s argument%s: %U",
15591559
qualname,
15601560
len,
15611561
kind,

Python/crossinterp_data_lookup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ _PyBytes_GetXIDataWrapped(PyThreadState *tstate,
455455
return NULL;
456456
}
457457
if (size < sizeof(_PyBytes_data_t)) {
458-
PyErr_Format(PyExc_ValueError, "expected size >= %d, got %d",
458+
PyErr_Format(PyExc_ValueError, "expected size >= %zu, got %zu",
459459
sizeof(_PyBytes_data_t), size);
460460
return NULL;
461461
}

Python/getargs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2421,7 +2421,7 @@ vgetargskeywordsfast_impl(PyObject *const *args, Py_ssize_t nargs,
24212421
if (i < parser->min) {
24222422
/* Less arguments than required */
24232423
if (i < pos) {
2424-
Py_ssize_t min = Py_MIN(pos, parser->min);
2424+
int min = Py_MIN(pos, parser->min);
24252425
PyErr_Format(PyExc_TypeError,
24262426
"%.200s%s takes %s %d positional argument%s"
24272427
" (%zd given)",
@@ -2435,7 +2435,7 @@ vgetargskeywordsfast_impl(PyObject *const *args, Py_ssize_t nargs,
24352435
else {
24362436
keyword = PyTuple_GET_ITEM(kwtuple, i - pos);
24372437
PyErr_Format(PyExc_TypeError, "%.200s%s missing required "
2438-
"argument '%U' (pos %d)",
2438+
"argument '%U' (pos %zd)",
24392439
(parser->fname == NULL) ? "function" : parser->fname,
24402440
(parser->fname == NULL) ? "" : "()",
24412441
keyword, i+1);
@@ -2476,7 +2476,7 @@ vgetargskeywordsfast_impl(PyObject *const *args, Py_ssize_t nargs,
24762476
/* arg present in tuple and in dict */
24772477
PyErr_Format(PyExc_TypeError,
24782478
"argument for %.200s%s given by name ('%U') "
2479-
"and position (%d)",
2479+
"and position (%zd)",
24802480
(parser->fname == NULL) ? "function" : parser->fname,
24812481
(parser->fname == NULL) ? "" : "()",
24822482
keyword, i+1);

Python/interpconfig.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ interp_config_from_dict(PyObject *origdict, PyInterpreterConfig *config,
208208
}
209209
else if (unused > 0) {
210210
PyErr_Format(PyExc_ValueError,
211-
"config dict has %d extra items (%R)", unused, dict);
211+
"config dict has %zd extra items (%R)", unused, dict);
212212
goto error;
213213
}
214214

Python/pythonrun.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,11 +1382,11 @@ get_interactive_filename(PyObject *filename, Py_ssize_t count)
13821382
if (middle == NULL) {
13831383
return NULL;
13841384
}
1385-
result = PyUnicode_FromFormat("<%U-%d>", middle, count);
1385+
result = PyUnicode_FromFormat("<%U-%zd>", middle, count);
13861386
Py_DECREF(middle);
13871387
} else {
13881388
result = PyUnicode_FromFormat(
1389-
"%U-%d", filename, count);
1389+
"%U-%zd", filename, count);
13901390
}
13911391
return result;
13921392

0 commit comments

Comments
 (0)