use Py_ssize_t for ast sequence lengths

This commit is contained in:
Benjamin Peterson 2012-05-15 10:10:27 -07:00
parent c5f31ed63d
commit 77fa9379e2
2 changed files with 4 additions and 4 deletions

View file

@ -784,7 +784,7 @@ def visitModule(self, mod):
static PyObject* ast2obj_list(asdl_seq *seq, PyObject* (*func)(void*))
{
int i, n = asdl_seq_LEN(seq);
Py_ssize_t i, n = asdl_seq_LEN(seq);
PyObject *result = PyList_New(n);
PyObject *value;
if (!result)
@ -1106,7 +1106,7 @@ def set(self, field, value, depth):
# While the sequence elements are stored as void*,
# ast2obj_cmpop expects an enum
self.emit("{", depth)
self.emit("int i, n = asdl_seq_LEN(%s);" % value, depth+1)
self.emit("Py_ssize_t i, n = asdl_seq_LEN(%s);" % value, depth+1)
self.emit("value = PyList_New(n);", depth+1)
self.emit("if (!value) goto failed;", depth+1)
self.emit("for(i = 0; i < n; i++)", depth+1)

View file

@ -636,7 +636,7 @@ static int add_attributes(PyTypeObject* type, char**attrs, int num_fields)
static PyObject* ast2obj_list(asdl_seq *seq, PyObject* (*func)(void*))
{
int i, n = asdl_seq_LEN(seq);
Py_ssize_t i, n = asdl_seq_LEN(seq);
PyObject *result = PyList_New(n);
PyObject *value;
if (!result)
@ -2857,7 +2857,7 @@ ast2obj_expr(void* _o)
goto failed;
Py_DECREF(value);
{
int i, n = asdl_seq_LEN(o->v.Compare.ops);
Py_ssize_t i, n = asdl_seq_LEN(o->v.Compare.ops);
value = PyList_New(n);
if (!value) goto failed;
for(i = 0; i < n; i++)