summaryrefslogtreecommitdiff
path: root/Modules
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 /Modules
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 'Modules')
-rw-r--r--Modules/_ctypes/callbacks.c10
-rw-r--r--Modules/_ctypes/callproc.c6
-rw-r--r--Modules/_ctypes/malloc_closure.c2
-rw-r--r--Modules/_io/winconsoleio.c2
-rw-r--r--Modules/_localemodule.c2
-rw-r--r--Modules/_lzmamodule.c4
-rw-r--r--Modules/_multiprocessing/semaphore.c2
-rw-r--r--Modules/_ssl.c2
-rw-r--r--Modules/binascii.c2
-rw-r--r--Modules/socketmodule.c4
10 files changed, 18 insertions, 18 deletions
diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c
index ec9f44336e..5a8303fba2 100644
--- a/Modules/_ctypes/callbacks.c
+++ b/Modules/_ctypes/callbacks.c
@@ -160,14 +160,14 @@ static void _CallPythonObject(void *mem,
if (cnv)
dict = PyType_stgdict(cnv);
else {
- PrintError("Getting argument converter %d\n", i);
+ PrintError("Getting argument converter %zd\n", i);
goto Done;
}
if (dict && dict->getfunc && !_ctypes_simple_instance(cnv)) {
PyObject *v = dict->getfunc(*pArgs, dict->size);
if (!v) {
- PrintError("create argument %d:\n", i);
+ PrintError("create argument %zd:\n", i);
Py_DECREF(cnv);
goto Done;
}
@@ -181,14 +181,14 @@ static void _CallPythonObject(void *mem,
/* Hm, shouldn't we use PyCData_AtAddress() or something like that instead? */
CDataObject *obj = (CDataObject *)_PyObject_CallNoArg(cnv);
if (!obj) {
- PrintError("create argument %d:\n", i);
+ PrintError("create argument %zd:\n", i);
Py_DECREF(cnv);
goto Done;
}
if (!CDataObject_Check(obj)) {
Py_DECREF(obj);
Py_DECREF(cnv);
- PrintError("unexpected result of create argument %d:\n", i);
+ PrintError("unexpected result of create argument %zd:\n", i);
goto Done;
}
memcpy(obj->b_ptr, *pArgs, dict->size);
@@ -199,7 +199,7 @@ static void _CallPythonObject(void *mem,
} else {
PyErr_SetString(PyExc_TypeError,
"cannot build parameter");
- PrintError("Parsing argument %d\n", i);
+ PrintError("Parsing argument %zd\n", i);
Py_DECREF(cnv);
goto Done;
}
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c
index e971388f69..ec854c864c 100644
--- a/Modules/_ctypes/callproc.c
+++ b/Modules/_ctypes/callproc.c
@@ -1125,20 +1125,20 @@ PyObject *_ctypes_callproc(PPROC pProc,
converter = PyTuple_GET_ITEM(argtypes, i);
v = PyObject_CallFunctionObjArgs(converter, arg, NULL);
if (v == NULL) {
- _ctypes_extend_error(PyExc_ArgError, "argument %d: ", i+1);
+ _ctypes_extend_error(PyExc_ArgError, "argument %zd: ", i+1);
goto cleanup;
}
err = ConvParam(v, i+1, pa);
Py_DECREF(v);
if (-1 == err) {
- _ctypes_extend_error(PyExc_ArgError, "argument %d: ", i+1);
+ _ctypes_extend_error(PyExc_ArgError, "argument %zd: ", i+1);
goto cleanup;
}
} else {
err = ConvParam(arg, i+1, pa);
if (-1 == err) {
- _ctypes_extend_error(PyExc_ArgError, "argument %d: ", i+1);
+ _ctypes_extend_error(PyExc_ArgError, "argument %zd: ", i+1);
goto cleanup; /* leaking ? */
}
}
diff --git a/Modules/_ctypes/malloc_closure.c b/Modules/_ctypes/malloc_closure.c
index 248c6a6702..8ad76497c7 100644
--- a/Modules/_ctypes/malloc_closure.c
+++ b/Modules/_ctypes/malloc_closure.c
@@ -76,7 +76,7 @@ static void more_core(void)
#ifdef MALLOC_CLOSURE_DEBUG
printf("block at %p allocated (%d bytes), %d ITEMs\n",
- item, count * sizeof(ITEM), count);
+ item, count * (int)sizeof(ITEM), count);
#endif
/* put them into the free list */
for (i = 0; i < count; ++i) {
diff --git a/Modules/_io/winconsoleio.c b/Modules/_io/winconsoleio.c
index c11c1e09f4..bf5b10b494 100644
--- a/Modules/_io/winconsoleio.c
+++ b/Modules/_io/winconsoleio.c
@@ -724,7 +724,7 @@ readinto(winconsoleio *self, char *buf, Py_ssize_t len)
if (u8n) {
PyErr_Format(PyExc_SystemError,
- "Buffer had room for %d bytes but %d bytes required",
+ "Buffer had room for %zd bytes but %u bytes required",
len, u8n);
return -1;
}
diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c
index 8efda35dd4..f946898118 100644
--- a/Modules/_localemodule.c
+++ b/Modules/_localemodule.c
@@ -394,7 +394,7 @@ PyLocale_getdefaultlocale(PyObject* self)
char encoding[100];
char locale[100];
- PyOS_snprintf(encoding, sizeof(encoding), "cp%d", GetACP());
+ PyOS_snprintf(encoding, sizeof(encoding), "cp%u", GetACP());
if (GetLocaleInfo(LOCALE_USER_DEFAULT,
LOCALE_SISO639LANGNAME,
diff --git a/Modules/_lzmamodule.c b/Modules/_lzmamodule.c
index bb7a7ec50c..f93c6c668e 100644
--- a/Modules/_lzmamodule.c
+++ b/Modules/_lzmamodule.c
@@ -219,7 +219,7 @@ parse_filter_spec_lzma(PyObject *spec)
if (lzma_lzma_preset(options, preset)) {
PyMem_Free(options);
- PyErr_Format(Error, "Invalid compression preset: %d", preset);
+ PyErr_Format(Error, "Invalid compression preset: %u", preset);
return NULL;
}
@@ -630,7 +630,7 @@ Compressor_init_alone(lzma_stream *lzs, uint32_t preset, PyObject *filterspecs)
lzma_options_lzma options;
if (lzma_lzma_preset(&options, preset)) {
- PyErr_Format(Error, "Invalid compression preset: %d", preset);
+ PyErr_Format(Error, "Invalid compression preset: %u", preset);
return -1;
}
lzret = lzma_alone_encoder(lzs, &options);
diff --git a/Modules/_multiprocessing/semaphore.c b/Modules/_multiprocessing/semaphore.c
index 0cc46b5322..0f3e33d91e 100644
--- a/Modules/_multiprocessing/semaphore.c
+++ b/Modules/_multiprocessing/semaphore.c
@@ -141,7 +141,7 @@ semlock_acquire(SemLockObject *self, PyObject *args, PyObject *kwds)
default:
PyErr_Format(PyExc_RuntimeError, "WaitForSingleObject() or "
"WaitForMultipleObjects() gave unrecognized "
- "value %d", res);
+ "value %u", res);
return NULL;
}
}
diff --git a/Modules/_ssl.c b/Modules/_ssl.c
index 9baec8a9bc..7076fddf8d 100644
--- a/Modules/_ssl.c
+++ b/Modules/_ssl.c
@@ -3348,7 +3348,7 @@ _ssl__SSLContext__set_alpn_protocols_impl(PySSLContext *self,
#if HAVE_ALPN
if ((size_t)protos->len > UINT_MAX) {
PyErr_Format(PyExc_OverflowError,
- "protocols longer than %d bytes", UINT_MAX);
+ "protocols longer than %u bytes", UINT_MAX);
return NULL;
}
diff --git a/Modules/binascii.c b/Modules/binascii.c
index d0d3f7d34b..c13bed6bbf 100644
--- a/Modules/binascii.c
+++ b/Modules/binascii.c
@@ -520,7 +520,7 @@ binascii_a2b_base64_impl(PyObject *module, Py_buffer *data)
*/
PyErr_Format(Error,
"Invalid base64-encoded string: "
- "number of data characters (%d) cannot be 1 more "
+ "number of data characters (%zd) cannot be 1 more "
"than a multiple of 4",
(bin_data - bin_data_start) / 3 * 4 + 1);
} else {
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 988471e15f..65385e8974 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -4102,7 +4102,7 @@ sock_sendto(PySocketSockObject *s, PyObject *args)
break;
default:
PyErr_Format(PyExc_TypeError,
- "sendto() takes 2 or 3 arguments (%d given)",
+ "sendto() takes 2 or 3 arguments (%zd given)",
arglen);
return NULL;
}
@@ -4642,7 +4642,7 @@ sock_ioctl(PySocketSockObject *s, PyObject *arg)
return PyLong_FromUnsignedLong(recv); }
#endif
default:
- PyErr_Format(PyExc_ValueError, "invalid ioctl command %d", cmd);
+ PyErr_Format(PyExc_ValueError, "invalid ioctl command %lu", cmd);
return NULL;
}
}