summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2019-03-14 10:47:27 +0200
committerGitHub <noreply@github.com>2019-03-14 10:47:27 +0200
commit783bed4c8daf65a2893d94761ea44af4e3718f4f (patch)
treecf5ce9cca23905968219200014eef4e7506b7563 /Python
parenta84f9bc11c3ce4854f7b4e16f3cb3cca954092f6 (diff)
downloadcpython-git-783bed4c8daf65a2893d94761ea44af4e3718f4f.tar.gz
[3.7] bpo-36254: Fix invalid uses of %d in format strings in C. (GH-12264). (GH-12322)
(cherry picked from commit d53fe5f407ff4b529628b01a1bcbf21a6aad5c3a) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Python')
-rw-r--r--Python/dynload_win.c2
-rw-r--r--Python/getargs.c12
-rw-r--r--Python/hamt.c2
-rw-r--r--Python/pyarena.c2
4 files changed, 9 insertions, 9 deletions
diff --git a/Python/dynload_win.c b/Python/dynload_win.c
index 0fdf77f552..51325be658 100644
--- a/Python/dynload_win.c
+++ b/Python/dynload_win.c
@@ -254,7 +254,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 992cb216c2..73e47f8456 100644
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -371,14 +371,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);
@@ -1718,7 +1718,7 @@ vgetargskeywords(PyObject *args, PyObject *kwargs, const char *format,
else {
PyErr_Format(PyExc_TypeError,
"%.200s%s takes %s %d positional arguments"
- " (%d given)",
+ " (%zd given)",
(fname == NULL) ? "function" : fname,
(fname == NULL) ? "" : "()",
(min != INT_MAX) ? "at most" : "exactly",
@@ -1797,7 +1797,7 @@ vgetargskeywords(PyObject *args, PyObject *kwargs, const char *format,
if (skip) {
PyErr_Format(PyExc_TypeError,
"%.200s%s takes %s %d positional arguments"
- " (%d given)",
+ " (%zd given)",
(fname == NULL) ? "function" : fname,
(fname == NULL) ? "" : "()",
(Py_MIN(pos, min) < i) ? "at least" : "exactly",
@@ -2103,7 +2103,7 @@ vgetargskeywordsfast_impl(PyObject *const *args, Py_ssize_t nargs,
}
else {
PyErr_Format(PyExc_TypeError,
- "%.200s%s takes %s %d positional arguments (%d given)",
+ "%.200s%s takes %s %d positional arguments (%zd given)",
(parser->fname == NULL) ? "function" : parser->fname,
(parser->fname == NULL) ? "" : "()",
(parser->min != INT_MAX) ? "at most" : "exactly",
@@ -2152,7 +2152,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 arguments"
- " (%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 562f777ea0..71a5ec87c5 100644
--- a/Python/hamt.c
+++ b/Python/hamt.c
@@ -2003,7 +2003,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 103603fcdf..d2aa8b8c32 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));