bpo-40943: Replace PY_FORMAT_SIZE_T with "z" (GH-20781)
The PEP 353, written in 2005, introduced PY_FORMAT_SIZE_T. Python no
longer supports macOS 10.4 and Visual Studio 2010, but requires more
recent macOS and Visual Studio versions. In 2020 with Python 3.10, it
is now safe to use directly "%zu" to format size_t and "%zi" to
format Py_ssize_t.
diff --git a/Python/getargs.c b/Python/getargs.c
index 524ad91..d2dba49 100644
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -452,7 +452,7 @@
}
if (iarg != 0) {
PyOS_snprintf(p, sizeof(buf) - (p - buf),
- "argument %" PY_FORMAT_SIZE_T "d", iarg);
+ "argument %zd", iarg);
i = 0;
p += strlen(p);
while (i < 32 && levels[i] > 0 && (int)(p-buf) < 220) {
@@ -540,15 +540,14 @@
levels[0] = 0;
if (toplevel) {
PyOS_snprintf(msgbuf, bufsize,
- "expected %d argument%s, not %" PY_FORMAT_SIZE_T "d",
+ "expected %d argument%s, not %zd",
n,
n == 1 ? "" : "s",
len);
}
else {
PyOS_snprintf(msgbuf, bufsize,
- "must be sequence of length %d, "
- "not %" PY_FORMAT_SIZE_T "d",
+ "must be sequence of length %d, not %zd",
n, len);
}
return msgbuf;