Skip to content

Commit 7a30be3

Browse files
sunmy2019miss-islington
authored andcommitted
gh-146615: Fix format specifiers in Python/ directory (GH-146619)
(cherry picked from commit dcb260e) Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
1 parent 99f333d commit 7a30be3

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
@@ -1530,7 +1530,7 @@ map_next(PyObject *self)
15301530
// ValueError: map() argument 3 is shorter than arguments 1-2
15311531
const char* plural = i == 1 ? " " : "s 1-";
15321532
PyErr_Format(PyExc_ValueError,
1533-
"map() argument %d is shorter than argument%s%d",
1533+
"map() argument %zd is shorter than argument%s%zd",
15341534
i + 1, plural, i);
15351535
goto exit_no_result;
15361536
}
@@ -1541,7 +1541,7 @@ map_next(PyObject *self)
15411541
Py_DECREF(val);
15421542
const char* plural = i == 1 ? " " : "s 1-";
15431543
PyErr_Format(PyExc_ValueError,
1544-
"map() argument %d is longer than argument%s%d",
1544+
"map() argument %zd is longer than argument%s%zd",
15451545
i + 1, plural, i);
15461546
goto exit_no_result;
15471547
}
@@ -3230,7 +3230,7 @@ zip_next(PyObject *self)
32303230
// ValueError: zip() argument 3 is shorter than arguments 1-2
32313231
const char* plural = i == 1 ? " " : "s 1-";
32323232
return PyErr_Format(PyExc_ValueError,
3233-
"zip() argument %d is shorter than argument%s%d",
3233+
"zip() argument %zd is shorter than argument%s%zd",
32343234
i + 1, plural, i);
32353235
}
32363236
for (i = 1; i < tuplesize; i++) {
@@ -3240,7 +3240,7 @@ zip_next(PyObject *self)
32403240
Py_DECREF(item);
32413241
const char* plural = i == 1 ? " " : "s 1-";
32423242
return PyErr_Format(PyExc_ValueError,
3243-
"zip() argument %d is longer than argument%s%d",
3243+
"zip() argument %zd is longer than argument%s%zd",
32443244
i + 1, plural, i);
32453245
}
32463246
if (PyErr_Occurred()) {

Python/ceval.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ _PyEval_MatchClass(PyThreadState *tstate, PyObject *subject, PyObject *type,
890890
if (allowed < nargs) {
891891
const char *plural = (allowed == 1) ? "" : "s";
892892
_PyErr_Format(tstate, PyExc_TypeError,
893-
"%s() accepts %d positional sub-pattern%s (%d given)",
893+
"%s() accepts %zd positional sub-pattern%s (%zd given)",
894894
((PyTypeObject*)type)->tp_name,
895895
allowed, plural, nargs);
896896
goto fail;
@@ -1436,7 +1436,7 @@ format_missing(PyThreadState *tstate, const char *kind,
14361436
if (name_str == NULL)
14371437
return;
14381438
_PyErr_Format(tstate, PyExc_TypeError,
1439-
"%U() missing %i required %s argument%s: %U",
1439+
"%U() missing %zd required %s argument%s: %U",
14401440
qualname,
14411441
len,
14421442
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
@@ -2278,7 +2278,7 @@ vgetargskeywordsfast_impl(PyObject *const *args, Py_ssize_t nargs,
22782278
if (i < parser->min) {
22792279
/* Less arguments than required */
22802280
if (i < pos) {
2281-
Py_ssize_t min = Py_MIN(pos, parser->min);
2281+
int min = Py_MIN(pos, parser->min);
22822282
PyErr_Format(PyExc_TypeError,
22832283
"%.200s%s takes %s %d positional argument%s"
22842284
" (%zd given)",
@@ -2292,7 +2292,7 @@ vgetargskeywordsfast_impl(PyObject *const *args, Py_ssize_t nargs,
22922292
else {
22932293
keyword = PyTuple_GET_ITEM(kwtuple, i - pos);
22942294
PyErr_Format(PyExc_TypeError, "%.200s%s missing required "
2295-
"argument '%U' (pos %d)",
2295+
"argument '%U' (pos %zd)",
22962296
(parser->fname == NULL) ? "function" : parser->fname,
22972297
(parser->fname == NULL) ? "" : "()",
22982298
keyword, i+1);
@@ -2333,7 +2333,7 @@ vgetargskeywordsfast_impl(PyObject *const *args, Py_ssize_t nargs,
23332333
/* arg present in tuple and in dict */
23342334
PyErr_Format(PyExc_TypeError,
23352335
"argument for %.200s%s given by name ('%U') "
2336-
"and position (%d)",
2336+
"and position (%zd)",
23372337
(parser->fname == NULL) ? "function" : parser->fname,
23382338
(parser->fname == NULL) ? "" : "()",
23392339
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
@@ -1379,11 +1379,11 @@ get_interactive_filename(PyObject *filename, Py_ssize_t count)
13791379
if (middle == NULL) {
13801380
return NULL;
13811381
}
1382-
result = PyUnicode_FromFormat("<%U-%d>", middle, count);
1382+
result = PyUnicode_FromFormat("<%U-%zd>", middle, count);
13831383
Py_DECREF(middle);
13841384
} else {
13851385
result = PyUnicode_FromFormat(
1386-
"%U-%d", filename, count);
1386+
"%U-%zd", filename, count);
13871387
}
13881388
return result;
13891389

0 commit comments

Comments
 (0)