Skip to content

Commit 1c396e1

Browse files
authored
gh-146615: Fix format specifiers in extension modules (GH-146617)
1 parent 72d29ea commit 1c396e1

File tree

6 files changed

+13
-18
lines changed

6 files changed

+13
-18
lines changed

Modules/_asynciomodule.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,7 +2244,7 @@ enter_task(_PyThreadStateImpl *ts, PyObject *loop, PyObject *task)
22442244
PyExc_RuntimeError,
22452245
"Cannot enter into task %R while another " \
22462246
"task %R is being executed.",
2247-
task, ts->asyncio_running_task, NULL);
2247+
task, ts->asyncio_running_task);
22482248
return -1;
22492249
}
22502250

@@ -2265,7 +2265,7 @@ leave_task(_PyThreadStateImpl *ts, PyObject *loop, PyObject *task)
22652265
PyExc_RuntimeError,
22662266
"Invalid attempt to leave task %R while " \
22672267
"task %R is entered.",
2268-
task, ts->asyncio_running_task ? ts->asyncio_running_task : Py_None, NULL);
2268+
task, ts->asyncio_running_task ? ts->asyncio_running_task : Py_None);
22692269
return -1;
22702270
}
22712271
Py_CLEAR(ts->asyncio_running_task);
@@ -2328,7 +2328,7 @@ _asyncio_Task___init___impl(TaskObj *self, PyObject *coro, PyObject *loop,
23282328
self->task_log_destroy_pending = 0;
23292329
PyErr_Format(PyExc_TypeError,
23302330
"a coroutine was expected, got %R",
2331-
coro, NULL);
2331+
coro);
23322332
return -1;
23332333
}
23342334

Modules/_remote_debugging/asyncio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ parse_task_name(
212212
set_exception_cause(unwinder, PyExc_RuntimeError, "Task name PyLong parsing failed");
213213
return NULL;
214214
}
215-
return PyUnicode_FromFormat("Task-%d", res);
215+
return PyUnicode_FromFormat("Task-%ld", res);
216216
}
217217

218218
if(!(GET_MEMBER(unsigned long, type_obj, unwinder->debug_offsets.type_object.tp_flags) & Py_TPFLAGS_UNICODE_SUBCLASS)) {

Modules/_ssl.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ fill_and_set_sslerror(_sslmodulestate *state,
592592
}
593593
else {
594594
if (PyUnicodeWriter_Format(
595-
writer, "unknown error (0x%x)", errcode) < 0) {
595+
writer, "unknown error (0x%lx)", errcode) < 0) {
596596
goto fail;
597597
}
598598
}
@@ -4016,15 +4016,11 @@ _ssl__SSLContext_verify_flags_set_impl(PySSLContext *self, PyObject *value)
40164016
static int
40174017
set_min_max_proto_version(PySSLContext *self, PyObject *arg, int what)
40184018
{
4019-
long v;
4019+
int v;
40204020
int result;
40214021

4022-
if (!PyArg_Parse(arg, "l", &v))
4022+
if (!PyArg_Parse(arg, "i", &v))
40234023
return -1;
4024-
if (v > INT_MAX) {
4025-
PyErr_SetString(PyExc_OverflowError, "Option is too long");
4026-
return -1;
4027-
}
40284024

40294025
switch(self->protocol) {
40304026
case PY_SSL_VERSION_TLS_CLIENT: _Py_FALLTHROUGH;
@@ -4059,7 +4055,7 @@ set_min_max_proto_version(PySSLContext *self, PyObject *arg, int what)
40594055
break;
40604056
default:
40614057
PyErr_Format(PyExc_ValueError,
4062-
"Unsupported TLS/SSL version 0x%x", v);
4058+
"Unsupported TLS/SSL version 0x%x", (unsigned)v);
40634059
return -1;
40644060
}
40654061

@@ -4093,7 +4089,7 @@ set_min_max_proto_version(PySSLContext *self, PyObject *arg, int what)
40934089
}
40944090
if (result == 0) {
40954091
PyErr_Format(PyExc_ValueError,
4096-
"Unsupported protocol version 0x%x", v);
4092+
"Unsupported protocol version 0x%x", (unsigned)v);
40974093
return -1;
40984094
}
40994095
return 0;

Modules/_zoneinfo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ load_data(zoneinfo_state *state, PyZoneInfo_ZoneInfo *self, PyObject *file_obj)
991991
}
992992

993993
if (!PyTuple_CheckExact(data_tuple)) {
994-
PyErr_Format(PyExc_TypeError, "Invalid data result type: %r",
994+
PyErr_Format(PyExc_TypeError, "Invalid data result type: %R",
995995
data_tuple);
996996
goto error;
997997
}

Modules/binascii.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,7 +1350,7 @@ binascii_a2b_base85_impl(PyObject *module, Py_buffer *data,
13501350
state = get_binascii_state(module);
13511351
if (state != NULL) {
13521352
PyErr_Format(state->Error,
1353-
"Base85 overflow in hunk starting at byte %d",
1353+
"Base85 overflow in hunk starting at byte %zd",
13541354
(data->len - ascii_len) / 5 * 5);
13551355
}
13561356
goto error;
@@ -1361,7 +1361,7 @@ binascii_a2b_base85_impl(PyObject *module, Py_buffer *data,
13611361
else {
13621362
state = get_binascii_state(module);
13631363
if (state != NULL) {
1364-
PyErr_Format(state->Error, "bad Base85 character at position %d",
1364+
PyErr_Format(state->Error, "bad Base85 character at position %zd",
13651365
data->len - ascii_len);
13661366
}
13671367
goto error;

Modules/socketmodule.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3357,8 +3357,7 @@ sock_setsockopt(PyObject *self, PyObject *args)
33573357
arglen = PyTuple_Size(args);
33583358
if (arglen == 3 && optval == Py_None) {
33593359
PyErr_Format(PyExc_TypeError,
3360-
"setsockopt() requires 4 arguments when the third argument is None",
3361-
arglen);
3360+
"setsockopt() requires 4 arguments when the third argument is None");
33623361
return NULL;
33633362
}
33643363
if (arglen == 4 && optval != Py_None) {

0 commit comments

Comments
 (0)