[Python-checkins] cpython (2.7): ctypes: the type of b_size is Py_ssize_t.

serhiy.storchaka python-checkins at python.org
Fri Jun 17 04:13:25 EDT 2016


https://hg.python.org/cpython/rev/dd2cc11bc170
changeset: 102069:dd2cc11bc170
branch: 2.7
parent: 102063:e04c054beb53
user: Serhiy Storchaka <storchaka at gmail.com>
date: Fri Jun 17 11:11:07 2016 +0300
summary:
 ctypes: the type of b_size is Py_ssize_t.
files:
 Modules/_ctypes/_ctypes.c | 8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -1174,7 +1174,7 @@
 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 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 @@
 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;
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /