Skip to content

Commit 58c7259

Browse files
[3.14] gh-146615: Fix format specifiers in extension modules (GH-146617) (GH-146652)
(cherry picked from commit 1c396e1) Co-authored-by: sunmy2019 <[email protected]>
1 parent e5ec90e commit 58c7259

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

Modules/_asynciomodule.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,7 +2255,7 @@ enter_task(PyObject *loop, PyObject *task)
22552255
PyExc_RuntimeError,
22562256
"Cannot enter into task %R while another " \
22572257
"task %R is being executed.",
2258-
task, ts->asyncio_running_task, NULL);
2258+
task, ts->asyncio_running_task);
22592259
return -1;
22602260
}
22612261

@@ -2278,7 +2278,7 @@ leave_task(PyObject *loop, PyObject *task)
22782278
PyExc_RuntimeError,
22792279
"Invalid attempt to leave task %R while " \
22802280
"task %R is entered.",
2281-
task, ts->asyncio_running_task ? ts->asyncio_running_task : Py_None, NULL);
2281+
task, ts->asyncio_running_task ? ts->asyncio_running_task : Py_None);
22822282
return -1;
22832283
}
22842284
Py_CLEAR(ts->asyncio_running_task);
@@ -2343,7 +2343,7 @@ _asyncio_Task___init___impl(TaskObj *self, PyObject *coro, PyObject *loop,
23432343
self->task_log_destroy_pending = 0;
23442344
PyErr_Format(PyExc_TypeError,
23452345
"a coroutine was expected, got %R",
2346-
coro, NULL);
2346+
coro);
23472347
return -1;
23482348
}
23492349

Modules/_ssl.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ fill_and_set_sslerror(_sslmodulestate *state,
577577
}
578578
else {
579579
if (PyUnicodeWriter_Format(
580-
writer, "unknown error (0x%x)", errcode) < 0) {
580+
writer, "unknown error (0x%lx)", errcode) < 0) {
581581
goto fail;
582582
}
583583
}
@@ -3597,15 +3597,11 @@ _ssl__SSLContext_verify_flags_set_impl(PySSLContext *self, PyObject *value)
35973597
static int
35983598
set_min_max_proto_version(PySSLContext *self, PyObject *arg, int what)
35993599
{
3600-
long v;
3600+
int v;
36013601
int result;
36023602

3603-
if (!PyArg_Parse(arg, "l", &v))
3603+
if (!PyArg_Parse(arg, "i", &v))
36043604
return -1;
3605-
if (v > INT_MAX) {
3606-
PyErr_SetString(PyExc_OverflowError, "Option is too long");
3607-
return -1;
3608-
}
36093605

36103606
switch(self->protocol) {
36113607
case PY_SSL_VERSION_TLS_CLIENT: _Py_FALLTHROUGH;
@@ -3640,7 +3636,7 @@ set_min_max_proto_version(PySSLContext *self, PyObject *arg, int what)
36403636
break;
36413637
default:
36423638
PyErr_Format(PyExc_ValueError,
3643-
"Unsupported TLS/SSL version 0x%x", v);
3639+
"Unsupported TLS/SSL version 0x%x", (unsigned)v);
36443640
return -1;
36453641
}
36463642

@@ -3674,7 +3670,7 @@ set_min_max_proto_version(PySSLContext *self, PyObject *arg, int what)
36743670
}
36753671
if (result == 0) {
36763672
PyErr_Format(PyExc_ValueError,
3677-
"Unsupported protocol version 0x%x", v);
3673+
"Unsupported protocol version 0x%x", (unsigned)v);
36783674
return -1;
36793675
}
36803676
return 0;

Modules/_zoneinfo.c

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

990990
if (!PyTuple_CheckExact(data_tuple)) {
991-
PyErr_Format(PyExc_TypeError, "Invalid data result type: %r",
991+
PyErr_Format(PyExc_TypeError, "Invalid data result type: %R",
992992
data_tuple);
993993
goto error;
994994
}

0 commit comments

Comments
 (0)