Skip to content

Commit 499df18

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

File tree

8 files changed

+15
-15
lines changed

8 files changed

+15
-15
lines changed

Objects/descrobject.c

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

Objects/enumobject.c

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

147147
PyErr_Format(PyExc_TypeError,
148-
"enumerate() takes at most 2 arguments (%d given)", nargs + nkwargs);
148+
"enumerate() takes at most 2 arguments (%zd given)", nargs + nkwargs);
149149
return NULL;
150150
}
151151

Objects/exceptions.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ BaseExceptionGroup_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
759759
if (!PyExceptionInstance_Check(exc)) {
760760
PyErr_Format(
761761
PyExc_ValueError,
762-
"Item %d of second argument (exceptions) is not an exception",
762+
"Item %zd of second argument (exceptions) is not an exception",
763763
i);
764764
goto error;
765765
}
@@ -1512,7 +1512,7 @@ PyUnstable_Exc_PrepReraiseStar(PyObject *orig, PyObject *excs)
15121512
PyObject *exc = PyList_GET_ITEM(excs, i);
15131513
if (exc == NULL || !(PyExceptionInstance_Check(exc) || Py_IsNone(exc))) {
15141514
PyErr_Format(PyExc_TypeError,
1515-
"item %d of excs is not an exception", i);
1515+
"item %zd of excs is not an exception", i);
15161516
return NULL;
15171517
}
15181518
}

Objects/funcobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ func_set_code(PyObject *self, PyObject *value, void *Py_UNUSED(ignored))
629629
if (nclosure != nfree) {
630630
PyErr_Format(PyExc_ValueError,
631631
"%U() requires a code object with %zd free vars,"
632-
" not %zd",
632+
" not %d",
633633
op->func_name,
634634
nclosure, nfree);
635635
return -1;
@@ -964,7 +964,7 @@ func_new_impl(PyTypeObject *type, PyCodeObject *code, PyObject *globals,
964964
nclosure = closure == Py_None ? 0 : PyTuple_GET_SIZE(closure);
965965
if (code->co_nfreevars != nclosure)
966966
return PyErr_Format(PyExc_ValueError,
967-
"%U requires closure of length %zd, not %zd",
967+
"%U requires closure of length %d, not %zd",
968968
code->co_name, code->co_nfreevars, nclosure);
969969
if (nclosure) {
970970
Py_ssize_t i;

Objects/memoryobject.c

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

24142414
if (nindices > view->ndim) {
24152415
PyErr_Format(PyExc_TypeError,
2416-
"cannot index %zd-dimension view with %zd-element tuple",
2416+
"cannot index %d-dimension view with %zd-element tuple",
24172417
view->ndim, nindices);
24182418
return NULL;
24192419
}

Objects/typeobject.c

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

44154415
if (type->tp_base && type->tp_base->tp_basicsize > type->tp_basicsize) {
44164416
PyErr_Format(PyExc_TypeError,
4417-
"tp_basicsize for type '%s' (%d) is too small for base '%s' (%d)",
4417+
"tp_basicsize for type '%s' (%zd) is too small for base '%s' (%zd)",
44184418
type->tp_name, type->tp_basicsize,
44194419
type->tp_base->tp_name, type->tp_base->tp_basicsize);
44204420
return 0;
44214421
}
44224422
if (type->tp_weaklistoffset + (Py_ssize_t)sizeof(PyObject*) > max) {
44234423
PyErr_Format(PyExc_TypeError,
4424-
"weaklist offset %d is out of bounds for type '%s' (tp_basicsize = %d)",
4424+
"weaklist offset %zd is out of bounds for type '%s' (tp_basicsize = %zd)",
44254425
type->tp_weaklistoffset,
44264426
type->tp_name, type->tp_basicsize);
44274427
return 0;
44284428
}
44294429
if (type->tp_dictoffset + (Py_ssize_t)sizeof(PyObject*) > max) {
44304430
PyErr_Format(PyExc_TypeError,
4431-
"dict offset %d is out of bounds for type '%s' (tp_basicsize = %d)",
4431+
"dict offset %zd is out of bounds for type '%s' (tp_basicsize = %zd)",
44324432
type->tp_dictoffset,
44334433
type->tp_name, type->tp_basicsize);
44344434
return 0;
44354435
}
44364436
if (type->tp_vectorcall_offset + (Py_ssize_t)sizeof(vectorcallfunc*) > max) {
44374437
PyErr_Format(PyExc_TypeError,
4438-
"vectorcall offset %d is out of bounds for type '%s' (tp_basicsize = %d)",
4438+
"vectorcall offset %zd is out of bounds for type '%s' (tp_basicsize = %zd)",
44394439
type->tp_vectorcall_offset,
44404440
type->tp_name, type->tp_basicsize);
44414441
return 0;

Objects/typevarobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ typevar_typing_prepare_subst_impl(typevarobject *self, PyObject *alias,
557557
}
558558
Py_DECREF(params);
559559
PyErr_Format(PyExc_TypeError,
560-
"Too few arguments for %S; actual %d, expected at least %d",
560+
"Too few arguments for %S; actual %zd, expected at least %zd",
561561
alias, args_len, i + 1);
562562
return NULL;
563563
}

Objects/unicodeobject.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8127,7 +8127,7 @@ charmap_decode_mapping(const char *s,
81278127
goto Undefined;
81288128
if (value < 0 || value > MAX_UNICODE) {
81298129
PyErr_Format(PyExc_TypeError,
8130-
"character mapping must be in range(0x%x)",
8130+
"character mapping must be in range(0x%lx)",
81318131
(unsigned long)MAX_UNICODE + 1);
81328132
goto onError;
81338133
}
@@ -8861,8 +8861,8 @@ charmaptranslate_lookup(Py_UCS4 c, PyObject *mapping, PyObject **result)
88618861
long value = PyLong_AS_LONG(x);
88628862
if (value < 0 || value > MAX_UNICODE) {
88638863
PyErr_Format(PyExc_ValueError,
8864-
"character mapping must be in range(0x%x)",
8865-
MAX_UNICODE+1);
8864+
"character mapping must be in range(0x%lx)",
8865+
(unsigned long)MAX_UNICODE + 1);
88668866
Py_DECREF(x);
88678867
return -1;
88688868
}

0 commit comments

Comments
 (0)