Skip to content

Commit 96fcf41

Browse files
committed
Fix format specifiers in error messages across multiple modules
1 parent 1fd66ea commit 96fcf41

File tree

7 files changed

+13
-14
lines changed

7 files changed

+13
-14
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: 3 additions & 3 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
}
@@ -4059,7 +4059,7 @@ set_min_max_proto_version(PySSLContext *self, PyObject *arg, int what)
40594059
break;
40604060
default:
40614061
PyErr_Format(PyExc_ValueError,
4062-
"Unsupported TLS/SSL version 0x%x", v);
4062+
"Unsupported TLS/SSL version 0x%lx", v);
40634063
return -1;
40644064
}
40654065

@@ -4093,7 +4093,7 @@ set_min_max_proto_version(PySSLContext *self, PyObject *arg, int what)
40934093
}
40944094
if (result == 0) {
40954095
PyErr_Format(PyExc_ValueError,
4096-
"Unsupported protocol version 0x%x", v);
4096+
"Unsupported protocol version 0x%lx", v);
40974097
return -1;
40984098
}
40994099
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/_zstd/compressor.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ zstd_contentsize_converter(PyObject *size, unsigned long long *p)
7474
if (PyErr_ExceptionMatches(PyExc_OverflowError)) {
7575
PyErr_Format(PyExc_ValueError,
7676
"size argument should be a positive int less "
77-
"than %ull", ZSTD_CONTENTSIZE_ERROR);
77+
"than %llu", ZSTD_CONTENTSIZE_ERROR);
7878
return 0;
7979
}
8080
return 0;
@@ -83,7 +83,7 @@ zstd_contentsize_converter(PyObject *size, unsigned long long *p)
8383
*p = ZSTD_CONTENTSIZE_ERROR;
8484
PyErr_Format(PyExc_ValueError,
8585
"size argument should be a positive int less "
86-
"than %ull", ZSTD_CONTENTSIZE_ERROR);
86+
"than %llu", ZSTD_CONTENTSIZE_ERROR);
8787
return 0;
8888
}
8989
*p = pledged_size;

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)