Skip to content

Commit e5ec90e

Browse files
[3.14] gh-146615: Fix format specifiers in Objects/ directory (GH-146620) (GH-146651)
(cherry picked from commit bbf7fb2) Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
1 parent 3866c29 commit e5ec90e

File tree

9 files changed

+16
-16
lines changed

9 files changed

+16
-16
lines changed

Objects/descrobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1607,7 +1607,7 @@ property_set_name(PyObject *self, PyObject *args) {
16071607
if (PyTuple_GET_SIZE(args) != 2) {
16081608
PyErr_Format(
16091609
PyExc_TypeError,
1610-
"__set_name__() takes 2 positional arguments but %d were given",
1610+
"__set_name__() takes 2 positional arguments but %zd were given",
16111611
PyTuple_GET_SIZE(args));
16121612
return NULL;
16131613
}

Objects/enumobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ enumerate_vectorcall(PyObject *type, PyObject *const *args,
148148
}
149149

150150
PyErr_Format(PyExc_TypeError,
151-
"enumerate() takes at most 2 arguments (%d given)", nargs + nkwargs);
151+
"enumerate() takes at most 2 arguments (%zd given)", nargs + nkwargs);
152152
return NULL;
153153
}
154154

Objects/exceptions.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ BaseExceptionGroup_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
943943
if (!PyExceptionInstance_Check(exc)) {
944944
PyErr_Format(
945945
PyExc_ValueError,
946-
"Item %d of second argument (exceptions) is not an exception",
946+
"Item %zd of second argument (exceptions) is not an exception",
947947
i);
948948
goto error;
949949
}
@@ -1724,7 +1724,7 @@ PyUnstable_Exc_PrepReraiseStar(PyObject *orig, PyObject *excs)
17241724
PyObject *exc = PyList_GET_ITEM(excs, i);
17251725
if (exc == NULL || !(PyExceptionInstance_Check(exc) || Py_IsNone(exc))) {
17261726
PyErr_Format(PyExc_TypeError,
1727-
"item %d of excs is not an exception", i);
1727+
"item %zd of excs is not an exception", i);
17281728
return NULL;
17291729
}
17301730
}

Objects/funcobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ func_set_code(PyObject *self, PyObject *value, void *Py_UNUSED(ignored))
681681
if (nclosure != nfree) {
682682
PyErr_Format(PyExc_ValueError,
683683
"%U() requires a code object with %zd free vars,"
684-
" not %zd",
684+
" not %d",
685685
op->func_name,
686686
nclosure, nfree);
687687
return -1;
@@ -1067,7 +1067,7 @@ func_new_impl(PyTypeObject *type, PyCodeObject *code, PyObject *globals,
10671067
nclosure = closure == Py_None ? 0 : PyTuple_GET_SIZE(closure);
10681068
if (code->co_nfreevars != nclosure)
10691069
return PyErr_Format(PyExc_ValueError,
1070-
"%U requires closure of length %zd, not %zd",
1070+
"%U requires closure of length %d, not %zd",
10711071
code->co_name, code->co_nfreevars, nclosure);
10721072
if (nclosure) {
10731073
Py_ssize_t i;

Objects/memoryobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2432,7 +2432,7 @@ ptr_from_tuple(const Py_buffer *view, PyObject *tup)
24322432

24332433
if (nindices > view->ndim) {
24342434
PyErr_Format(PyExc_TypeError,
2435-
"cannot index %zd-dimension view with %zd-element tuple",
2435+
"cannot index %d-dimension view with %zd-element tuple",
24362436
view->ndim, nindices);
24372437
return NULL;
24382438
}

Objects/typeobject.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4894,28 +4894,28 @@ check_basicsize_includes_size_and_offsets(PyTypeObject* type)
48944894

48954895
if (type->tp_base && type->tp_base->tp_basicsize > type->tp_basicsize) {
48964896
PyErr_Format(PyExc_TypeError,
4897-
"tp_basicsize for type '%s' (%d) is too small for base '%s' (%d)",
4897+
"tp_basicsize for type '%s' (%zd) is too small for base '%s' (%zd)",
48984898
type->tp_name, type->tp_basicsize,
48994899
type->tp_base->tp_name, type->tp_base->tp_basicsize);
49004900
return 0;
49014901
}
49024902
if (type->tp_weaklistoffset + (Py_ssize_t)sizeof(PyObject*) > max) {
49034903
PyErr_Format(PyExc_TypeError,
4904-
"weaklist offset %d is out of bounds for type '%s' (tp_basicsize = %d)",
4904+
"weaklist offset %zd is out of bounds for type '%s' (tp_basicsize = %zd)",
49054905
type->tp_weaklistoffset,
49064906
type->tp_name, type->tp_basicsize);
49074907
return 0;
49084908
}
49094909
if (type->tp_dictoffset + (Py_ssize_t)sizeof(PyObject*) > max) {
49104910
PyErr_Format(PyExc_TypeError,
4911-
"dict offset %d is out of bounds for type '%s' (tp_basicsize = %d)",
4911+
"dict offset %zd is out of bounds for type '%s' (tp_basicsize = %zd)",
49124912
type->tp_dictoffset,
49134913
type->tp_name, type->tp_basicsize);
49144914
return 0;
49154915
}
49164916
if (type->tp_vectorcall_offset + (Py_ssize_t)sizeof(vectorcallfunc*) > max) {
49174917
PyErr_Format(PyExc_TypeError,
4918-
"vectorcall offset %d is out of bounds for type '%s' (tp_basicsize = %d)",
4918+
"vectorcall offset %zd is out of bounds for type '%s' (tp_basicsize = %zd)",
49194919
type->tp_vectorcall_offset,
49204920
type->tp_name, type->tp_basicsize);
49214921
return 0;

Objects/typevarobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ typevar_typing_prepare_subst_impl(typevarobject *self, PyObject *alias,
816816
}
817817
Py_DECREF(params);
818818
PyErr_Format(PyExc_TypeError,
819-
"Too few arguments for %S; actual %d, expected at least %d",
819+
"Too few arguments for %S; actual %zd, expected at least %zd",
820820
alias, args_len, i + 1);
821821
return NULL;
822822
}

Objects/unicodeobject.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8550,7 +8550,7 @@ charmap_decode_mapping(const char *s,
85508550
goto Undefined;
85518551
if (value < 0 || value > MAX_UNICODE) {
85528552
PyErr_Format(PyExc_TypeError,
8553-
"character mapping must be in range(0x%x)",
8553+
"character mapping must be in range(0x%lx)",
85548554
(unsigned long)MAX_UNICODE + 1);
85558555
goto onError;
85568556
}
@@ -9299,8 +9299,8 @@ charmaptranslate_lookup(Py_UCS4 c, PyObject *mapping, PyObject **result, Py_UCS4
92999299
long value = PyLong_AsLong(x);
93009300
if (value < 0 || value > MAX_UNICODE) {
93019301
PyErr_Format(PyExc_ValueError,
9302-
"character mapping must be in range(0x%x)",
9303-
MAX_UNICODE+1);
9302+
"character mapping must be in range(0x%lx)",
9303+
(unsigned long)MAX_UNICODE + 1);
93049304
Py_DECREF(x);
93059305
return -1;
93069306
}

Objects/unionobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ union_hash(PyObject *self)
6161
}
6262
// The unhashable values somehow became hashable again. Still raise
6363
// an error.
64-
PyErr_Format(PyExc_TypeError, "union contains %d unhashable elements", n);
64+
PyErr_Format(PyExc_TypeError, "union contains %zd unhashable elements", n);
6565
return -1;
6666
}
6767
return PyObject_Hash(alias->hashable_args);

0 commit comments

Comments
 (0)