]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-146615: Fix format specifiers in Python/ directory (GH-146619) (GH-146650)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 31 Mar 2026 08:25:07 +0000 (10:25 +0200)
committerGitHub <noreply@github.com>
Tue, 31 Mar 2026 08:25:07 +0000 (08:25 +0000)
(cherry picked from commit dcb260eff2d276976933f78c24a4ebd0ed7dbc36)

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

index 9b9e56a5b117c09237efc36b4fe286a74f1c513b..603d9646ce58e43b507bf82997f7f03602d98dd9 100644 (file)
@@ -1530,7 +1530,7 @@ check:
         // ValueError: map() argument 3 is shorter than arguments 1-2
         const char* plural = i == 1 ? " " : "s 1-";
         PyErr_Format(PyExc_ValueError,
-                     "map() argument %d is shorter than argument%s%d",
+                     "map() argument %zd is shorter than argument%s%zd",
                      i + 1, plural, i);
         goto exit_no_result;
     }
@@ -1541,7 +1541,7 @@ check:
             Py_DECREF(val);
             const char* plural = i == 1 ? " " : "s 1-";
             PyErr_Format(PyExc_ValueError,
-                         "map() argument %d is longer than argument%s%d",
+                         "map() argument %zd is longer than argument%s%zd",
                          i + 1, plural, i);
             goto exit_no_result;
         }
@@ -3230,7 +3230,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++) {
@@ -3240,7 +3240,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 59c39214405689c08cb69b91a243eb5f34481fdb..377b4644eddd2a848ddad1e99ee22e1525b93f67 100644 (file)
@@ -890,7 +890,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;
@@ -1436,7 +1436,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 c3c76ae8d9a289b9dd1d44269b17a59db8dea9ee..cf84633e10e356ca50db3c44bc3ee51dc455ac25 100644 (file)
@@ -455,7 +455,7 @@ _PyBytes_GetXIDataWrapped(PyThreadState *tstate,
         return NULL;
     }
     if (size < sizeof(_PyBytes_data_t)) {
-        PyErr_Format(PyExc_ValueError, "expected size >= %d, got %d",
+        PyErr_Format(PyExc_ValueError, "expected size >= %zu, got %zu",
                      sizeof(_PyBytes_data_t), size);
         return NULL;
     }
index 9d3dea0cb4364b1c23ce239ed20273b11dd38841..43ceb2bf83597154c07a27db88cade51e579ad8c 100644 (file)
@@ -2278,7 +2278,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)",
@@ -2292,7 +2292,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);
@@ -2333,7 +2333,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 1add8a81425b9a816684650c47ce532005f82094..a37bd3f5b23a01ea281db6c377b83673008f0f80 100644 (file)
@@ -208,7 +208,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 91c81ac0d8d23743e3c16866e0d538cd4ac6ee92..263163f913c7a81ba2343203a513182ffa5359e9 100644 (file)
@@ -1379,11 +1379,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;