]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
use Py_ssize_t for ast sequence lengths
authorBenjamin Peterson <benjamin@python.org>
Tue, 15 May 2012 17:10:27 +0000 (10:10 -0700)
committerBenjamin Peterson <benjamin@python.org>
Tue, 15 May 2012 17:10:27 +0000 (10:10 -0700)
Parser/asdl_c.py
Python/Python-ast.c

index 81a3d6af588a51b926a21d5a0953a012faa9a2d3..769f73f0cb753e3adf159fd54014ed310003c08e 100755 (executable)
@@ -784,7 +784,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)
@@ -1106,7 +1106,7 @@ class ObjVisitor(PickleVisitor):
                 # 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)
index d9e13e28b0d97162729bd9d4b6ec0469491ca1c2..4ca269f9f542a9eecd5901f2519778e6e7cbd1c3 100644 (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++)