Skip to content

Commit bbf7fb2

Browse files
authored
gh-146615: Fix format specifiers in Objects/ directory (GH-146620)
1 parent dcb260e commit bbf7fb2

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
@@ -1610,7 +1610,7 @@ property_set_name(PyObject *self, PyObject *args) {
16101610
if (PyTuple_GET_SIZE(args) != 2) {
16111611
PyErr_Format(
16121612
PyExc_TypeError,
1613-
"__set_name__() takes 2 positional arguments but %d were given",
1613+
"__set_name__() takes 2 positional arguments but %zd were given",
16141614
PyTuple_GET_SIZE(args));
16151615
return NULL;
16161616
}

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
@@ -935,7 +935,7 @@ BaseExceptionGroup_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
935935
if (!PyExceptionInstance_Check(exc)) {
936936
PyErr_Format(
937937
PyExc_ValueError,
938-
"Item %d of second argument (exceptions) is not an exception",
938+
"Item %zd of second argument (exceptions) is not an exception",
939939
i);
940940
goto error;
941941
}
@@ -1714,7 +1714,7 @@ PyUnstable_Exc_PrepReraiseStar(PyObject *orig, PyObject *excs)
17141714
PyObject *exc = PyList_GET_ITEM(excs, i);
17151715
if (exc == NULL || !(PyExceptionInstance_Check(exc) || Py_IsNone(exc))) {
17161716
PyErr_Format(PyExc_TypeError,
1717-
"item %d of excs is not an exception", i);
1717+
"item %zd of excs is not an exception", i);
17181718
return NULL;
17191719
}
17201720
}

Objects/funcobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ func_set_code(PyObject *self, PyObject *value, void *Py_UNUSED(ignored))
657657
if (nclosure != nfree) {
658658
PyErr_Format(PyExc_ValueError,
659659
"%U() requires a code object with %zd free vars,"
660-
" not %zd",
660+
" not %d",
661661
op->func_name,
662662
nclosure, nfree);
663663
return -1;
@@ -1044,7 +1044,7 @@ func_new_impl(PyTypeObject *type, PyCodeObject *code, PyObject *globals,
10441044
nclosure = closure == Py_None ? 0 : PyTuple_GET_SIZE(closure);
10451045
if (code->co_nfreevars != nclosure)
10461046
return PyErr_Format(PyExc_ValueError,
1047-
"%U requires closure of length %zd, not %zd",
1047+
"%U requires closure of length %d, not %zd",
10481048
code->co_name, code->co_nfreevars, nclosure);
10491049
if (nclosure) {
10501050
Py_ssize_t i;

Objects/memoryobject.c

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

24732473
if (nindices > view->ndim) {
24742474
PyErr_Format(PyExc_TypeError,
2475-
"cannot index %zd-dimension view with %zd-element tuple",
2475+
"cannot index %d-dimension view with %zd-element tuple",
24762476
view->ndim, nindices);
24772477
return NULL;
24782478
}

Objects/typeobject.c

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

51855185
if (type->tp_base && type->tp_base->tp_basicsize > type->tp_basicsize) {
51865186
PyErr_Format(PyExc_TypeError,
5187-
"tp_basicsize for type '%s' (%d) is too small for base '%s' (%d)",
5187+
"tp_basicsize for type '%s' (%zd) is too small for base '%s' (%zd)",
51885188
type->tp_name, type->tp_basicsize,
51895189
type->tp_base->tp_name, type->tp_base->tp_basicsize);
51905190
return 0;
51915191
}
51925192
if (type->tp_weaklistoffset + (Py_ssize_t)sizeof(PyObject*) > max) {
51935193
PyErr_Format(PyExc_TypeError,
5194-
"weaklist offset %d is out of bounds for type '%s' (tp_basicsize = %d)",
5194+
"weaklist offset %zd is out of bounds for type '%s' (tp_basicsize = %zd)",
51955195
type->tp_weaklistoffset,
51965196
type->tp_name, type->tp_basicsize);
51975197
return 0;
51985198
}
51995199
if (type->tp_dictoffset + (Py_ssize_t)sizeof(PyObject*) > max) {
52005200
PyErr_Format(PyExc_TypeError,
5201-
"dict offset %d is out of bounds for type '%s' (tp_basicsize = %d)",
5201+
"dict offset %zd is out of bounds for type '%s' (tp_basicsize = %zd)",
52025202
type->tp_dictoffset,
52035203
type->tp_name, type->tp_basicsize);
52045204
return 0;
52055205
}
52065206
if (type->tp_vectorcall_offset + (Py_ssize_t)sizeof(vectorcallfunc*) > max) {
52075207
PyErr_Format(PyExc_TypeError,
5208-
"vectorcall offset %d is out of bounds for type '%s' (tp_basicsize = %d)",
5208+
"vectorcall offset %zd is out of bounds for type '%s' (tp_basicsize = %zd)",
52095209
type->tp_vectorcall_offset,
52105210
type->tp_name, type->tp_basicsize);
52115211
return 0;

Objects/typevarobject.c

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

Objects/unicodeobject.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8350,7 +8350,7 @@ charmap_decode_mapping(const char *s,
83508350
goto Undefined;
83518351
if (value < 0 || value > MAX_UNICODE) {
83528352
PyErr_Format(PyExc_TypeError,
8353-
"character mapping must be in range(0x%x)",
8353+
"character mapping must be in range(0x%lx)",
83548354
(unsigned long)MAX_UNICODE + 1);
83558355
goto onError;
83568356
}
@@ -9141,8 +9141,8 @@ charmaptranslate_lookup(Py_UCS4 c, PyObject *mapping, PyObject **result, Py_UCS4
91419141
long value = PyLong_AsLong(x);
91429142
if (value < 0 || value > MAX_UNICODE) {
91439143
PyErr_Format(PyExc_ValueError,
9144-
"character mapping must be in range(0x%x)",
9145-
MAX_UNICODE+1);
9144+
"character mapping must be in range(0x%lx)",
9145+
(unsigned long)MAX_UNICODE + 1);
91469146
Py_DECREF(x);
91479147
return -1;
91489148
}

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)