[Python-checkins] cpython: use Py_ssize_t for ast sequence lengths

benjamin.peterson python-checkins at python.org
Tue May 15 19:12:53 CEST 2012


http://hg.python.org/cpython/rev/c18a1a82bb07
changeset:   76964:c18a1a82bb07
parent:      76961:54d63a86a876
user:        Benjamin Peterson <benjamin at python.org>
date:        Tue May 15 10:10:27 2012 -0700
summary:
  use Py_ssize_t for ast sequence lengths

files:
  Parser/asdl_c.py    |  4 ++--
  Python/Python-ast.c |  4 ++--
  2 files changed, 4 insertions(+), 4 deletions(-)


diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
--- a/Parser/asdl_c.py
+++ b/Parser/asdl_c.py
@@ -784,7 +784,7 @@
 
 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 @@
                 # 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)
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -636,7 +636,7 @@
 
 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 @@
                         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++)

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list