[pypy-commit] pypy py3k-test-cpyext: Properly port array.c to py3: some of the tests pass with -A

rlamy pypy.commits at gmail.com
Sat Oct 1 22:57:51 EDT 2016


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3k-test-cpyext
Changeset: r87513:dd1c6ff22873
Date: 2016-10-02 03:22 +0100
http://bitbucket.org/pypy/pypy/changeset/dd1c6ff22873/

Log:	Properly port array.c to py3: some of the tests pass with -A

diff --git a/pypy/module/cpyext/test/array.c b/pypy/module/cpyext/test/array.c
--- a/pypy/module/cpyext/test/array.c
+++ b/pypy/module/cpyext/test/array.c
@@ -2339,7 +2339,7 @@
         int ii, nn;
         int n = PyList_Size(obj2);
         PyObject *v = getarrayitem(obj1, 0);
-        int i = ((PyIntObject*)v)->ob_ival;
+        long i = PyLong_AsLong(v);
         PyObject * ret = PyList_New(n*i);
         for (ii = 0; ii < i; ii++)
             for (nn = 0; nn < n; nn++)
@@ -2697,8 +2697,7 @@
     PyObject_GenericGetAttr,                    /* tp_getattro */
     0,                                          /* tp_setattro */
     &array_as_buffer,                           /* tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | 
-    Py_TPFLAGS_HAVE_WEAKREFS | Py_TPFLAGS_CHECKTYPES,  /* tp_flags */
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,  /* tp_flags */
     arraytype_doc,                              /* tp_doc */
     0,                                          /* tp_traverse */
     0,                                          /* tp_clear */
@@ -2740,8 +2739,7 @@
     PyObject_GenericGetAttr,                    /* tp_getattro */
     0,                                          /* tp_setattro */
     &array_as_buffer,                           /* tp_as_buffer*/
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | 
-    Py_TPFLAGS_HAVE_WEAKREFS | Py_TPFLAGS_CHECKTYPES,  /* tp_flags */
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,  /* tp_flags */
     arraytype_doc,                              /* tp_doc */
     0,                                          /* tp_traverse */
     0,                                          /* tp_clear */
@@ -2888,7 +2886,7 @@
     register Py_UNICODE *p;
     struct arraydescr *descr;
 
-    ArrayBasetype.ob_type = &PyType_Type;
+    Py_TYPE(&ArrayBasetype) = &PyType_Type;
     Arraytype.tp_base = &ArrayBasetype;
     if (PyType_Ready(&Arraytype) < 0)
         return NULL;


More information about the pypy-commit mailing list