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.
This commit is contained in:
Victor Stinner 2020-06-10 18:38:05 +02:00 committed by GitHub
parent 24b8bad6d3
commit d36cf5f1d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 89 additions and 101 deletions

View file

@ -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
}