]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-146615: Fix format specifiers in Objects/ directory (GH-146620) (GH-146655)
authorSerhiy Storchaka <storchaka@gmail.com>
Tue, 31 Mar 2026 08:44:51 +0000 (11:44 +0300)
committerGitHub <noreply@github.com>
Tue, 31 Mar 2026 08:44:51 +0000 (08:44 +0000)
(cherry picked from commit bbf7fb2c15a1dc9a54d10937c3d0831b0968257d)

Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
Objects/descrobject.c
Objects/enumobject.c
Objects/exceptions.c
Objects/funcobject.c
Objects/memoryobject.c
Objects/typeobject.c
Objects/typevarobject.c
Objects/unicodeobject.c

index d33152bb85489e73cb4a9ab755d9a6e3fe3cf5b1..a0d9220259cb804892de08845d6ddf44684d900a 100644 (file)
@@ -1606,7 +1606,7 @@ property_set_name(PyObject *self, PyObject *args) {
     if (PyTuple_GET_SIZE(args) != 2) {
         PyErr_Format(
                 PyExc_TypeError,
-                "__set_name__() takes 2 positional arguments but %d were given",
+                "__set_name__() takes 2 positional arguments but %zd were given",
                 PyTuple_GET_SIZE(args));
         return NULL;
     }
index 556666779d85229356a6641219bb661e0e9bde17..bffe7172a393d786e11fb6ab7d2ba23c76a437be 100644 (file)
@@ -145,7 +145,7 @@ enumerate_vectorcall(PyObject *type, PyObject *const *args,
     }
 
     PyErr_Format(PyExc_TypeError,
-        "enumerate() takes at most 2 arguments (%d given)", nargs + nkwargs);
+        "enumerate() takes at most 2 arguments (%zd given)", nargs + nkwargs);
     return NULL;
 }
 
index 6c1807715c0f146bcce4d2980c7d4fb48d92b033..1eb2a3bbe24571d32624a69c1db7dd1ffb299971 100644 (file)
@@ -759,7 +759,7 @@ BaseExceptionGroup_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
         if (!PyExceptionInstance_Check(exc)) {
             PyErr_Format(
                 PyExc_ValueError,
-                "Item %d of second argument (exceptions) is not an exception",
+                "Item %zd of second argument (exceptions) is not an exception",
                 i);
             goto error;
         }
@@ -1512,7 +1512,7 @@ PyUnstable_Exc_PrepReraiseStar(PyObject *orig, PyObject *excs)
         PyObject *exc = PyList_GET_ITEM(excs, i);
         if (exc == NULL || !(PyExceptionInstance_Check(exc) || Py_IsNone(exc))) {
             PyErr_Format(PyExc_TypeError,
-                         "item %d of excs is not an exception", i);
+                         "item %zd of excs is not an exception", i);
             return NULL;
         }
     }
index 61140fd4f1859ec7f6ff4e0f22169ac73f4ed8e4..a39b5464f4d4acf39fdcb903b5dffcd38c3353d9 100644 (file)
@@ -629,7 +629,7 @@ func_set_code(PyObject *self, PyObject *value, void *Py_UNUSED(ignored))
     if (nclosure != nfree) {
         PyErr_Format(PyExc_ValueError,
                      "%U() requires a code object with %zd free vars,"
-                     " not %zd",
+                     " not %d",
                      op->func_name,
                      nclosure, nfree);
         return -1;
@@ -964,7 +964,7 @@ func_new_impl(PyTypeObject *type, PyCodeObject *code, PyObject *globals,
     nclosure = closure == Py_None ? 0 : PyTuple_GET_SIZE(closure);
     if (code->co_nfreevars != nclosure)
         return PyErr_Format(PyExc_ValueError,
-                            "%U requires closure of length %zd, not %zd",
+                            "%U requires closure of length %d, not %zd",
                             code->co_name, code->co_nfreevars, nclosure);
     if (nclosure) {
         Py_ssize_t i;
index 8dc53c9ccbbacbd1941c04f1928cd41977690172..535e0b3c1dc0271403ee4130188967fad8b215f7 100644 (file)
@@ -2413,7 +2413,7 @@ ptr_from_tuple(const Py_buffer *view, PyObject *tup)
 
     if (nindices > view->ndim) {
         PyErr_Format(PyExc_TypeError,
-                     "cannot index %zd-dimension view with %zd-element tuple",
+                     "cannot index %d-dimension view with %zd-element tuple",
                      view->ndim, nindices);
         return NULL;
     }
index 0c16377034fbb78258679f8d027d551220adbc0b..51d1ce573d12e13b257ee69c986a152b15a27821 100644 (file)
@@ -4414,28 +4414,28 @@ check_basicsize_includes_size_and_offsets(PyTypeObject* type)
 
     if (type->tp_base && type->tp_base->tp_basicsize > type->tp_basicsize) {
         PyErr_Format(PyExc_TypeError,
-                     "tp_basicsize for type '%s' (%d) is too small for base '%s' (%d)",
+                     "tp_basicsize for type '%s' (%zd) is too small for base '%s' (%zd)",
                      type->tp_name, type->tp_basicsize,
                      type->tp_base->tp_name, type->tp_base->tp_basicsize);
         return 0;
     }
     if (type->tp_weaklistoffset + (Py_ssize_t)sizeof(PyObject*) > max) {
         PyErr_Format(PyExc_TypeError,
-                     "weaklist offset %d is out of bounds for type '%s' (tp_basicsize = %d)",
+                     "weaklist offset %zd is out of bounds for type '%s' (tp_basicsize = %zd)",
                      type->tp_weaklistoffset,
                      type->tp_name, type->tp_basicsize);
         return 0;
     }
     if (type->tp_dictoffset + (Py_ssize_t)sizeof(PyObject*) > max) {
         PyErr_Format(PyExc_TypeError,
-                     "dict offset %d is out of bounds for type '%s' (tp_basicsize = %d)",
+                     "dict offset %zd is out of bounds for type '%s' (tp_basicsize = %zd)",
                      type->tp_dictoffset,
                      type->tp_name, type->tp_basicsize);
         return 0;
     }
     if (type->tp_vectorcall_offset + (Py_ssize_t)sizeof(vectorcallfunc*) > max) {
         PyErr_Format(PyExc_TypeError,
-                     "vectorcall offset %d is out of bounds for type '%s' (tp_basicsize = %d)",
+                     "vectorcall offset %zd is out of bounds for type '%s' (tp_basicsize = %zd)",
                      type->tp_vectorcall_offset,
                      type->tp_name, type->tp_basicsize);
         return 0;
index 1398f911e54ef5cc9f40373aeb4d673ba80e92ef..5caec8a73bbddf76b08544d863a37cc2a374de38 100644 (file)
@@ -557,7 +557,7 @@ typevar_typing_prepare_subst_impl(typevarobject *self, PyObject *alias,
     }
     Py_DECREF(params);
     PyErr_Format(PyExc_TypeError,
-                 "Too few arguments for %S; actual %d, expected at least %d",
+                 "Too few arguments for %S; actual %zd, expected at least %zd",
                  alias, args_len, i + 1);
     return NULL;
 }
index 395430e398d50d5fd31ed53f15e0779faaf6120d..696bb100c6bf55eb529dfd988e177c381dcf8598 100644 (file)
@@ -8127,7 +8127,7 @@ charmap_decode_mapping(const char *s,
                 goto Undefined;
             if (value < 0 || value > MAX_UNICODE) {
                 PyErr_Format(PyExc_TypeError,
-                             "character mapping must be in range(0x%x)",
+                             "character mapping must be in range(0x%lx)",
                              (unsigned long)MAX_UNICODE + 1);
                 goto onError;
             }
@@ -8861,8 +8861,8 @@ charmaptranslate_lookup(Py_UCS4 c, PyObject *mapping, PyObject **result)
         long value = PyLong_AS_LONG(x);
         if (value < 0 || value > MAX_UNICODE) {
             PyErr_Format(PyExc_ValueError,
-                         "character mapping must be in range(0x%x)",
-                         MAX_UNICODE+1);
+                         "character mapping must be in range(0x%lx)",
+                         (unsigned long)MAX_UNICODE + 1);
             Py_DECREF(x);
             return -1;
         }