]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-146615: Fix format specifiers in Python/ directory (GH-146619) (GH-146654)
authorSerhiy Storchaka <storchaka@gmail.com>
Tue, 31 Mar 2026 09:16:44 +0000 (12:16 +0300)
committerGitHub <noreply@github.com>
Tue, 31 Mar 2026 09:16:44 +0000 (09:16 +0000)
(cherry picked from commit dcb260eff2d276976933f78c24a4ebd0ed7dbc36)

Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
Python/bltinmodule.c
Python/ceval.c
Python/getargs.c
Python/interpconfig.c
Python/pythonrun.c

index 5ded0bba13b16df5d648721c29e5f4b7b7269625..bcf7e7355daa99ea9579857e99b1afc9a24481a5 100644 (file)
@@ -2973,7 +2973,7 @@ check:
         // ValueError: zip() argument 3 is shorter than arguments 1-2
         const char* plural = i == 1 ? " " : "s 1-";
         return PyErr_Format(PyExc_ValueError,
-                            "zip() argument %d is shorter than argument%s%d",
+                            "zip() argument %zd is shorter than argument%s%zd",
                             i + 1, plural, i);
     }
     for (i = 1; i < tuplesize; i++) {
@@ -2983,7 +2983,7 @@ check:
             Py_DECREF(item);
             const char* plural = i == 1 ? " " : "s 1-";
             return PyErr_Format(PyExc_ValueError,
-                                "zip() argument %d is longer than argument%s%d",
+                                "zip() argument %zd is longer than argument%s%zd",
                                 i + 1, plural, i);
         }
         if (PyErr_Occurred()) {
index aafb4dd0fd97d37788dec0a1d62ebfd100b5914f..7a4e704a4b5580eb468237215caa92edf8d584fa 100644 (file)
@@ -513,7 +513,7 @@ _PyEval_MatchClass(PyThreadState *tstate, PyObject *subject, PyObject *type,
         if (allowed < nargs) {
             const char *plural = (allowed == 1) ? "" : "s";
             _PyErr_Format(tstate, PyExc_TypeError,
-                          "%s() accepts %d positional sub-pattern%s (%d given)",
+                          "%s() accepts %zd positional sub-pattern%s (%zd given)",
                           ((PyTypeObject*)type)->tp_name,
                           allowed, plural, nargs);
             goto fail;
@@ -1183,7 +1183,7 @@ format_missing(PyThreadState *tstate, const char *kind,
     if (name_str == NULL)
         return;
     _PyErr_Format(tstate, PyExc_TypeError,
-                  "%U() missing %i required %s argument%s: %U",
+                  "%U() missing %zd required %s argument%s: %U",
                   qualname,
                   len,
                   kind,
index e95ccec851fb38d7ce48bcd3e6aac347109898a7..1bf99fe33c8a3590ff18174994c6e3dc4e58a58b 100644 (file)
@@ -2189,7 +2189,7 @@ vgetargskeywordsfast_impl(PyObject *const *args, Py_ssize_t nargs,
         if (i < parser->min) {
             /* Less arguments than required */
             if (i < pos) {
-                Py_ssize_t min = Py_MIN(pos, parser->min);
+                int min = Py_MIN(pos, parser->min);
                 PyErr_Format(PyExc_TypeError,
                              "%.200s%s takes %s %d positional argument%s"
                              " (%zd given)",
@@ -2203,7 +2203,7 @@ vgetargskeywordsfast_impl(PyObject *const *args, Py_ssize_t nargs,
             else {
                 keyword = PyTuple_GET_ITEM(kwtuple, i - pos);
                 PyErr_Format(PyExc_TypeError,  "%.200s%s missing required "
-                             "argument '%U' (pos %d)",
+                             "argument '%U' (pos %zd)",
                              (parser->fname == NULL) ? "function" : parser->fname,
                              (parser->fname == NULL) ? "" : "()",
                              keyword, i+1);
@@ -2244,7 +2244,7 @@ vgetargskeywordsfast_impl(PyObject *const *args, Py_ssize_t nargs,
                 /* arg present in tuple and in dict */
                 PyErr_Format(PyExc_TypeError,
                              "argument for %.200s%s given by name ('%U') "
-                             "and position (%d)",
+                             "and position (%zd)",
                              (parser->fname == NULL) ? "function" : parser->fname,
                              (parser->fname == NULL) ? "" : "()",
                              keyword, i+1);
index 54e5dca284c215870d006e13683bda423184984d..27f4793cd2f5550bcb5937247bb6c4cf548f012f 100644 (file)
@@ -207,7 +207,7 @@ interp_config_from_dict(PyObject *origdict, PyInterpreterConfig *config,
     }
     else if (unused > 0) {
         PyErr_Format(PyExc_ValueError,
-                     "config dict has %d extra items (%R)", unused, dict);
+                     "config dict has %zd extra items (%R)", unused, dict);
         goto error;
     }
 
index c4a1275eb524d6573d3369854eb6fad807e18ae2..632d2c56a6763895c46ded5f7ab29e02693ab2dd 100644 (file)
@@ -1398,11 +1398,11 @@ get_interactive_filename(PyObject *filename, Py_ssize_t count)
         if (middle == NULL) {
             return NULL;
         }
-        result = PyUnicode_FromFormat("<%U-%d>", middle, count);
+        result = PyUnicode_FromFormat("<%U-%zd>", middle, count);
         Py_DECREF(middle);
     } else {
         result = PyUnicode_FromFormat(
-            "%U-%d", filename, count);
+            "%U-%zd", filename, count);
     }
     return result;