Issue #22207: Fix "comparison between signed and unsigned integers" warning in

test checking for integer overflow on Py_ssize_t type: cast explicitly to
size_t.
This commit is contained in:
Victor Stinner 2014-08-17 22:20:00 +02:00
parent daca3d7e9b
commit 049e509a9f
8 changed files with 21 additions and 19 deletions

View file

@ -699,7 +699,7 @@ unicode_internal_encode(PyObject *self,
u = PyUnicode_AsUnicodeAndSize(obj, &len);
if (u == NULL)
return NULL;
if (len > PY_SSIZE_T_MAX / sizeof(Py_UNICODE))
if ((size_t)len > (size_t)PY_SSIZE_T_MAX / sizeof(Py_UNICODE))
return PyErr_NoMemory();
size = len * sizeof(Py_UNICODE);
return codec_tuple(PyBytes_FromStringAndSize((const char*)u, size),