summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-06-10 16:38:05 (GMT)
committerGitHub <noreply@github.com>2020-06-10 16:38:05 (GMT)
commitd36cf5f1d20ce9f111a8fc997104785086e8eee6 (patch)
treef452121f147dece783aa9a278f6ce80b012ca0bd /Python
parent24b8bad6d30ae4fb37ee686a073adfa5308659f9 (diff)
downloadcpython-d36cf5f1d20ce9f111a8fc997104785086e8eee6.zip
cpython-d36cf5f1d20ce9f111a8fc997104785086e8eee6.tar.gz
cpython-d36cf5f1d20ce9f111a8fc997104785086e8eee6.tar.bz2
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.
Diffstat (limited to 'Python')
-rw-r--r--Python/getargs.c7
-rw-r--r--Python/pyhash.c12
2 files changed, 7 insertions, 12 deletions
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 @@ seterror(Py_ssize_t iarg, const char *msg, int *levels, const char *fname,
}
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 @@ converttuple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
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;
diff --git a/Python/pyhash.c b/Python/pyhash.c
index 3843079..3b6c34e 100644
--- a/Python/pyhash.c
+++ b/Python/pyhash.c
@@ -200,18 +200,14 @@ void
_PyHash_Fini(void)
{
#ifdef Py_HASH_STATS
- int i;
- Py_ssize_t total = 0;
- const char *fmt = "%2i %8" PY_FORMAT_SIZE_T "d %8" PY_FORMAT_SIZE_T "d\n";
-
fprintf(stderr, "len calls total\n");
- for (i = 1; i <= Py_HASH_STATS_MAX; i++) {
+ Py_ssize_t total = 0;
+ for (int i = 1; i <= Py_HASH_STATS_MAX; i++) {
total += hashstats[i];
- fprintf(stderr, fmt, i, hashstats[i], total);
+ fprintf(stderr, "%2i %8zd %8zd\n", i, hashstats[i], total);
}
total += hashstats[0];
- fprintf(stderr, "> %8" PY_FORMAT_SIZE_T "d %8" PY_FORMAT_SIZE_T "d\n",
- hashstats[0], total);
+ fprintf(stderr, "> %8zd %8zd\n", hashstats[0], total);
#endif
}