Skip to content

Commit e726d28

Browse files
[3.13] gh-146615: Fix format specifiers in Python/ directory (GH-146619) (GH-146654)
(cherry picked from commit dcb260e) Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
1 parent 499df18 commit e726d28

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

Python/bltinmodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2973,7 +2973,7 @@ zip_next(zipobject *lz)
29732973
// ValueError: zip() argument 3 is shorter than arguments 1-2
29742974
const char* plural = i == 1 ? " " : "s 1-";
29752975
return PyErr_Format(PyExc_ValueError,
2976-
"zip() argument %d is shorter than argument%s%d",
2976+
"zip() argument %zd is shorter than argument%s%zd",
29772977
i + 1, plural, i);
29782978
}
29792979
for (i = 1; i < tuplesize; i++) {
@@ -2983,7 +2983,7 @@ zip_next(zipobject *lz)
29832983
Py_DECREF(item);
29842984
const char* plural = i == 1 ? " " : "s 1-";
29852985
return PyErr_Format(PyExc_ValueError,
2986-
"zip() argument %d is longer than argument%s%d",
2986+
"zip() argument %zd is longer than argument%s%zd",
29872987
i + 1, plural, i);
29882988
}
29892989
if (PyErr_Occurred()) {

Python/ceval.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ _PyEval_MatchClass(PyThreadState *tstate, PyObject *subject, PyObject *type,
513513
if (allowed < nargs) {
514514
const char *plural = (allowed == 1) ? "" : "s";
515515
_PyErr_Format(tstate, PyExc_TypeError,
516-
"%s() accepts %d positional sub-pattern%s (%d given)",
516+
"%s() accepts %zd positional sub-pattern%s (%zd given)",
517517
((PyTypeObject*)type)->tp_name,
518518
allowed, plural, nargs);
519519
goto fail;
@@ -1183,7 +1183,7 @@ format_missing(PyThreadState *tstate, const char *kind,
11831183
if (name_str == NULL)
11841184
return;
11851185
_PyErr_Format(tstate, PyExc_TypeError,
1186-
"%U() missing %i required %s argument%s: %U",
1186+
"%U() missing %zd required %s argument%s: %U",
11871187
qualname,
11881188
len,
11891189
kind,

Python/getargs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2189,7 +2189,7 @@ vgetargskeywordsfast_impl(PyObject *const *args, Py_ssize_t nargs,
21892189
if (i < parser->min) {
21902190
/* Less arguments than required */
21912191
if (i < pos) {
2192-
Py_ssize_t min = Py_MIN(pos, parser->min);
2192+
int min = Py_MIN(pos, parser->min);
21932193
PyErr_Format(PyExc_TypeError,
21942194
"%.200s%s takes %s %d positional argument%s"
21952195
" (%zd given)",
@@ -2203,7 +2203,7 @@ vgetargskeywordsfast_impl(PyObject *const *args, Py_ssize_t nargs,
22032203
else {
22042204
keyword = PyTuple_GET_ITEM(kwtuple, i - pos);
22052205
PyErr_Format(PyExc_TypeError, "%.200s%s missing required "
2206-
"argument '%U' (pos %d)",
2206+
"argument '%U' (pos %zd)",
22072207
(parser->fname == NULL) ? "function" : parser->fname,
22082208
(parser->fname == NULL) ? "" : "()",
22092209
keyword, i+1);
@@ -2244,7 +2244,7 @@ vgetargskeywordsfast_impl(PyObject *const *args, Py_ssize_t nargs,
22442244
/* arg present in tuple and in dict */
22452245
PyErr_Format(PyExc_TypeError,
22462246
"argument for %.200s%s given by name ('%U') "
2247-
"and position (%d)",
2247+
"and position (%zd)",
22482248
(parser->fname == NULL) ? "function" : parser->fname,
22492249
(parser->fname == NULL) ? "" : "()",
22502250
keyword, i+1);

Python/interpconfig.c

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

Python/pythonrun.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,11 +1398,11 @@ get_interactive_filename(PyObject *filename, Py_ssize_t count)
13981398
if (middle == NULL) {
13991399
return NULL;
14001400
}
1401-
result = PyUnicode_FromFormat("<%U-%d>", middle, count);
1401+
result = PyUnicode_FromFormat("<%U-%zd>", middle, count);
14021402
Py_DECREF(middle);
14031403
} else {
14041404
result = PyUnicode_FromFormat(
1405-
"%U-%d", filename, count);
1405+
"%U-%zd", filename, count);
14061406
}
14071407
return result;
14081408

0 commit comments

Comments
 (0)