summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2019-03-13 20:59:55 (GMT)
committerGitHub <noreply@github.com>2019-03-13 20:59:55 (GMT)
commitd53fe5f407ff4b529628b01a1bcbf21a6aad5c3a (patch)
treedb8a8657e379e60b26fe2bfdbad4da612fbb46b9 /Python
parent10f8ce66884cd7fee2372b8dae08ca8132091574 (diff)
downloadcpython-d53fe5f407ff4b529628b01a1bcbf21a6aad5c3a.zip
cpython-d53fe5f407ff4b529628b01a1bcbf21a6aad5c3a.tar.gz
cpython-d53fe5f407ff4b529628b01a1bcbf21a6aad5c3a.tar.bz2
bpo-36254: Fix invalid uses of %d in format strings in C. (GH-12264)
Diffstat (limited to 'Python')
-rw-r--r--Python/coreconfig.c2
-rw-r--r--Python/dynload_win.c2
-rw-r--r--Python/getargs.c10
-rw-r--r--Python/hamt.c2
-rw-r--r--Python/pyarena.c2
5 files changed, 9 insertions, 9 deletions
diff --git a/Python/coreconfig.c b/Python/coreconfig.c
index cd4ef22..845e4c9 100644
--- a/Python/coreconfig.c
+++ b/Python/coreconfig.c
@@ -1103,7 +1103,7 @@ get_locale_encoding(char **locale_encoding)
{
#ifdef MS_WINDOWS
char encoding[20];
- PyOS_snprintf(encoding, sizeof(encoding), "cp%d", GetACP());
+ PyOS_snprintf(encoding, sizeof(encoding), "cp%u", GetACP());
#elif defined(__ANDROID__) || defined(__VXWORKS__)
const char *encoding = "UTF-8";
#else
diff --git a/Python/dynload_win.c b/Python/dynload_win.c
index 129e04d..36918c3 100644
--- a/Python/dynload_win.c
+++ b/Python/dynload_win.c
@@ -256,7 +256,7 @@ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix,
This should not happen if called correctly. */
if (theLength == 0) {
message = PyUnicode_FromFormat(
- "DLL load failed with error code %d",
+ "DLL load failed with error code %u",
errorCode);
} else {
/* For some reason a \r\n
diff --git a/Python/getargs.c b/Python/getargs.c
index ba1a9d4..876f5c7 100644
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -372,14 +372,14 @@ vgetargs1_impl(PyObject *compat_args, PyObject *const *stack, Py_ssize_t nargs,
if (nargs < min || max < nargs) {
if (message == NULL)
PyErr_Format(PyExc_TypeError,
- "%.150s%s takes %s %d argument%s (%ld given)",
+ "%.150s%s takes %s %d argument%s (%zd given)",
fname==NULL ? "function" : fname,
fname==NULL ? "" : "()",
min==max ? "exactly"
: nargs < min ? "at least" : "at most",
nargs < min ? min : max,
(nargs < min ? min : max) == 1 ? "" : "s",
- Py_SAFE_DOWNCAST(nargs, Py_ssize_t, long));
+ nargs);
else
PyErr_SetString(PyExc_TypeError, message);
return cleanreturn(0, &freelist);
@@ -1741,7 +1741,7 @@ vgetargskeywords(PyObject *args, PyObject *kwargs, const char *format,
else {
PyErr_Format(PyExc_TypeError,
"%.200s%s takes %s %d positional argument%s"
- " (%d given)",
+ " (%zd given)",
(fname == NULL) ? "function" : fname,
(fname == NULL) ? "" : "()",
(min != INT_MAX) ? "at most" : "exactly",
@@ -1826,7 +1826,7 @@ vgetargskeywords(PyObject *args, PyObject *kwargs, const char *format,
if (skip) {
PyErr_Format(PyExc_TypeError,
"%.200s%s takes %s %d positional argument%s"
- " (%d given)",
+ " (%zd given)",
(fname == NULL) ? "function" : fname,
(fname == NULL) ? "" : "()",
(Py_MIN(pos, min) < i) ? "at least" : "exactly",
@@ -2194,7 +2194,7 @@ vgetargskeywordsfast_impl(PyObject *const *args, Py_ssize_t nargs,
Py_ssize_t min = Py_MIN(pos, parser->min);
PyErr_Format(PyExc_TypeError,
"%.200s%s takes %s %d positional argument%s"
- " (%d given)",
+ " (%zd given)",
(parser->fname == NULL) ? "function" : parser->fname,
(parser->fname == NULL) ? "" : "()",
min < parser->max ? "at least" : "exactly",
diff --git a/Python/hamt.c b/Python/hamt.c
index aa90d37..67af04c 100644
--- a/Python/hamt.c
+++ b/Python/hamt.c
@@ -2005,7 +2005,7 @@ hamt_node_array_dump(PyHamtNode_Array *node,
goto error;
}
- if (_hamt_dump_format(writer, "%d::\n", i)) {
+ if (_hamt_dump_format(writer, "%zd::\n", i)) {
goto error;
}
diff --git a/Python/pyarena.c b/Python/pyarena.c
index abb5729..aefb787 100644
--- a/Python/pyarena.c
+++ b/Python/pyarena.c
@@ -160,7 +160,7 @@ PyArena_Free(PyArena *arena)
#if defined(Py_DEBUG)
/*
fprintf(stderr,
- "alloc=%d size=%d blocks=%d block_size=%d big=%d objects=%d\n",
+ "alloc=%zu size=%zu blocks=%zu block_size=%zu big=%zu objects=%zu\n",
arena->total_allocs, arena->total_size, arena->total_blocks,
arena->total_block_size, arena->total_big_blocks,
PyList_Size(arena->a_objects));