[Python-checkins] cpython: Widen ASDL sequences to Py_ssize_t lengths to better match PEP 353.

martin.v.loewis python-checkins at python.org
Tue May 15 14:45:23 CEST 2012


http://hg.python.org/cpython/rev/f4d7ad6c9d6e
changeset:   76947:f4d7ad6c9d6e
user:        Martin v. Löwis <martin at v.loewis.de>
date:        Tue May 15 14:45:03 2012 +0200
summary:
  Widen ASDL sequences to Py_ssize_t lengths to better match PEP 353.

files:
  Include/asdl.h      |  8 ++++----
  Python/Python-ast.c |  4 ++--
  Python/asdl.c       |  4 ++--
  3 files changed, 8 insertions(+), 8 deletions(-)


diff --git a/Include/asdl.h b/Include/asdl.h
--- a/Include/asdl.h
+++ b/Include/asdl.h
@@ -15,17 +15,17 @@
 /* XXX A sequence should be typed so that its use can be typechecked. */
 
 typedef struct {
-    int size;
+    Py_ssize_t size;
     void *elements[1];
 } asdl_seq;
 
 typedef struct {
-    int size;
+    Py_ssize_t size;
     int elements[1];
 } asdl_int_seq;
 
-asdl_seq *asdl_seq_new(int size, PyArena *arena);
-asdl_int_seq *asdl_int_seq_new(int size, PyArena *arena);
+asdl_seq *asdl_seq_new(Py_ssize_t size, PyArena *arena);
+asdl_int_seq *asdl_int_seq_new(Py_ssize_t size, PyArena *arena);
 
 #define asdl_seq_GET(S, I) (S)->elements[(I)]
 #define asdl_seq_LEN(S) ((S) == NULL ? 0 : (S)->size)
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++)
diff --git a/Python/asdl.c b/Python/asdl.c
--- a/Python/asdl.c
+++ b/Python/asdl.c
@@ -2,7 +2,7 @@
 #include "asdl.h"
 
 asdl_seq *
-asdl_seq_new(int size, PyArena *arena)
+asdl_seq_new(Py_ssize_t size, PyArena *arena)
 {
     asdl_seq *seq = NULL;
     size_t n = (size ? (sizeof(void *) * (size - 1)) : 0);
@@ -33,7 +33,7 @@
 }
 
 asdl_int_seq *
-asdl_int_seq_new(int size, PyArena *arena)
+asdl_int_seq_new(Py_ssize_t size, PyArena *arena)
 {
     asdl_int_seq *seq = NULL;
     size_t n = (size ? (sizeof(void *) * (size - 1)) : 0);

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


More information about the Python-checkins mailing list