https://github.com/python/cpython/commit/1c396e18218daa723b425af0781c5e762d7717c2
commit: 1c396e18218daa723b425af0781c5e762d7717c2
branch: main
author: sunmy2019 <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2026-03-31T10:57:37+03:00
summary:

gh-146615: Fix format specifiers in extension modules (GH-146617)

files:
M Modules/_asynciomodule.c
M Modules/_remote_debugging/asyncio.c
M Modules/_ssl.c
M Modules/_zoneinfo.c
M Modules/binascii.c
M Modules/socketmodule.c

diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c
index 826c0b25a362c2..bd294648ca222f 100644
--- a/Modules/_asynciomodule.c
+++ b/Modules/_asynciomodule.c
@@ -2244,7 +2244,7 @@ enter_task(_PyThreadStateImpl *ts, PyObject *loop, 
PyObject *task)
             PyExc_RuntimeError,
             "Cannot enter into task %R while another " \
             "task %R is being executed.",
-            task, ts->asyncio_running_task, NULL);
+            task, ts->asyncio_running_task);
         return -1;
     }
 
@@ -2265,7 +2265,7 @@ leave_task(_PyThreadStateImpl *ts, PyObject *loop, 
PyObject *task)
             PyExc_RuntimeError,
             "Invalid attempt to leave task %R while " \
             "task %R is entered.",
-            task, ts->asyncio_running_task ? ts->asyncio_running_task : 
Py_None, NULL);
+            task, ts->asyncio_running_task ? ts->asyncio_running_task : 
Py_None);
         return -1;
     }
     Py_CLEAR(ts->asyncio_running_task);
@@ -2328,7 +2328,7 @@ _asyncio_Task___init___impl(TaskObj *self, PyObject 
*coro, PyObject *loop,
         self->task_log_destroy_pending = 0;
         PyErr_Format(PyExc_TypeError,
                      "a coroutine was expected, got %R",
-                     coro, NULL);
+                     coro);
         return -1;
     }
 
diff --git a/Modules/_remote_debugging/asyncio.c 
b/Modules/_remote_debugging/asyncio.c
index 12a8a9acc13bac..263c502a857004 100644
--- a/Modules/_remote_debugging/asyncio.c
+++ b/Modules/_remote_debugging/asyncio.c
@@ -212,7 +212,7 @@ parse_task_name(
             set_exception_cause(unwinder, PyExc_RuntimeError, "Task name 
PyLong parsing failed");
             return NULL;
         }
-        return PyUnicode_FromFormat("Task-%d", res);
+        return PyUnicode_FromFormat("Task-%ld", res);
     }
 
     if(!(GET_MEMBER(unsigned long, type_obj, 
unwinder->debug_offsets.type_object.tp_flags) & Py_TPFLAGS_UNICODE_SUBCLASS)) {
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index d42a4e7f7078e6..b93bbe8ddf5a83 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -592,7 +592,7 @@ fill_and_set_sslerror(_sslmodulestate *state,
     }
     else {
         if (PyUnicodeWriter_Format(
-                writer, "unknown error (0x%x)", errcode) < 0) {
+                writer, "unknown error (0x%lx)", errcode) < 0) {
             goto fail;
         }
     }
@@ -4016,15 +4016,11 @@ _ssl__SSLContext_verify_flags_set_impl(PySSLContext 
*self, PyObject *value)
 static int
 set_min_max_proto_version(PySSLContext *self, PyObject *arg, int what)
 {
-    long v;
+    int v;
     int result;
 
-    if (!PyArg_Parse(arg, "l", &v))
+    if (!PyArg_Parse(arg, "i", &v))
         return -1;
-    if (v > INT_MAX) {
-        PyErr_SetString(PyExc_OverflowError, "Option is too long");
-        return -1;
-    }
 
     switch(self->protocol) {
     case PY_SSL_VERSION_TLS_CLIENT: _Py_FALLTHROUGH;
@@ -4059,7 +4055,7 @@ set_min_max_proto_version(PySSLContext *self, PyObject 
*arg, int what)
             break;
         default:
             PyErr_Format(PyExc_ValueError,
-                     "Unsupported TLS/SSL version 0x%x", v);
+                     "Unsupported TLS/SSL version 0x%x", (unsigned)v);
             return -1;
     }
 
@@ -4093,7 +4089,7 @@ set_min_max_proto_version(PySSLContext *self, PyObject 
*arg, int what)
     }
     if (result == 0) {
         PyErr_Format(PyExc_ValueError,
-                     "Unsupported protocol version 0x%x", v);
+                     "Unsupported protocol version 0x%x", (unsigned)v);
         return -1;
     }
     return 0;
diff --git a/Modules/_zoneinfo.c b/Modules/_zoneinfo.c
index 159cac3c06601a..aa0b1302cb2fc6 100644
--- a/Modules/_zoneinfo.c
+++ b/Modules/_zoneinfo.c
@@ -991,7 +991,7 @@ load_data(zoneinfo_state *state, PyZoneInfo_ZoneInfo *self, 
PyObject *file_obj)
     }
 
     if (!PyTuple_CheckExact(data_tuple)) {
-        PyErr_Format(PyExc_TypeError, "Invalid data result type: %r",
+        PyErr_Format(PyExc_TypeError, "Invalid data result type: %R",
                      data_tuple);
         goto error;
     }
diff --git a/Modules/binascii.c b/Modules/binascii.c
index dbe77ff248d34e..c51bb9c3c77371 100644
--- a/Modules/binascii.c
+++ b/Modules/binascii.c
@@ -1350,7 +1350,7 @@ binascii_a2b_base85_impl(PyObject *module, Py_buffer 
*data,
                 state = get_binascii_state(module);
                 if (state != NULL) {
                     PyErr_Format(state->Error,
-                                 "Base85 overflow in hunk starting at byte %d",
+                                 "Base85 overflow in hunk starting at byte 
%zd",
                                  (data->len - ascii_len) / 5 * 5);
                 }
                 goto error;
@@ -1361,7 +1361,7 @@ binascii_a2b_base85_impl(PyObject *module, Py_buffer 
*data,
         else {
             state = get_binascii_state(module);
             if (state != NULL) {
-                PyErr_Format(state->Error, "bad Base85 character at position 
%d",
+                PyErr_Format(state->Error, "bad Base85 character at position 
%zd",
                              data->len - ascii_len);
             }
             goto error;
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 1cedd64e0e9953..a97b09a4f5df0e 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -3357,8 +3357,7 @@ sock_setsockopt(PyObject *self, PyObject *args)
     arglen = PyTuple_Size(args);
     if (arglen == 3 && optval == Py_None) {
         PyErr_Format(PyExc_TypeError,
-                     "setsockopt() requires 4 arguments when the third 
argument is None",
-                     arglen);
+                     "setsockopt() requires 4 arguments when the third 
argument is None");
         return NULL;
     }
     if (arglen == 4 && optval != Py_None) {

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to