ctypes: the type of b_size is Py_ssize_t.

This commit is contained in:
Serhiy Storchaka 2016-06-17 11:11:07 +03:00
parent ef012cc7f7
commit f46d3afc51
1 changed files with 4 additions and 4 deletions

View File

@ -1174,7 +1174,7 @@ CharArray_get_raw(CDataObject *self)
static PyObject *
CharArray_get_value(CDataObject *self)
{
int i;
Py_ssize_t i;
char *ptr = self->b_ptr;
for (i = 0; i < self->b_size; ++i)
if (*ptr++ == '\0')
@ -1236,9 +1236,9 @@ static PyGetSetDef CharArray_getsets[] = {
static PyObject *
WCharArray_get_value(CDataObject *self)
{
unsigned int i;
Py_ssize_t i;
wchar_t *ptr = (wchar_t *)self->b_ptr;
for (i = 0; i < self->b_size/sizeof(wchar_t); ++i)
for (i = 0; i < self->b_size/(Py_ssize_t)sizeof(wchar_t); ++i)
if (*ptr++ == (wchar_t)0)
break;
return PyUnicode_FromWideChar((wchar_t *)self->b_ptr, i);
@ -1267,7 +1267,7 @@ WCharArray_set_value(CDataObject *self, PyObject *value)
return -1;
} else
Py_INCREF(value);
if ((unsigned)PyUnicode_GET_SIZE(value) > self->b_size/sizeof(wchar_t)) {
if ((size_t)PyUnicode_GET_SIZE(value) > self->b_size/sizeof(wchar_t)) {
PyErr_SetString(PyExc_ValueError,
"string too long");
result = -1;