[pypy-commit] pypy default: test and fix for cpyext/listobject.py: PyList_GET_SIZE and PyList_SetItem

l.diekmann noreply at buildbot.pypy.org
Sat Jan 28 14:01:01 CET 2012


Author: Lukas Diekmann <lukas.diekmann at uni-duesseldorf.de>
Branch: 
Changeset: r51907:a384864c5d6c
Date: 2012-01-28 12:39 +0100
http://bitbucket.org/pypy/pypy/changeset/a384864c5d6c/

Log:	test and fix for cpyext/listobject.py: PyList_GET_SIZE and
	PyList_SetItem

diff --git a/pypy/module/cpyext/listobject.py b/pypy/module/cpyext/listobject.py
--- a/pypy/module/cpyext/listobject.py
+++ b/pypy/module/cpyext/listobject.py
@@ -32,11 +32,10 @@
     Py_DecRef(space, w_item)
     if not isinstance(w_list, W_ListObject):
         PyErr_BadInternalCall(space)
-    wrappeditems = w_list.getitems()
-    if index < 0 or index >= len(wrappeditems):
+    if index < 0 or index >= w_list.length():
         raise OperationError(space.w_IndexError, space.wrap(
             "list assignment index out of range"))
-    wrappeditems[index] = w_item
+    w_list.setitem(index, w_item)
     return 0
 
 @cpython_api([PyObject, Py_ssize_t], PyObject)
@@ -74,7 +73,7 @@
     """Macro form of PyList_Size() without error checking.
     """
     assert isinstance(w_list, W_ListObject)
-    return len(w_list.getitems())
+    return w_list.length()
 
 
 @cpython_api([PyObject], Py_ssize_t, error=-1)
diff --git a/pypy/module/cpyext/test/test_listobject.py b/pypy/module/cpyext/test/test_listobject.py
--- a/pypy/module/cpyext/test/test_listobject.py
+++ b/pypy/module/cpyext/test/test_listobject.py
@@ -128,3 +128,6 @@
         module.setslice(l, None)
         assert l == [0, 4, 5]
 
+        l = [1, 2, 3]
+        module.setlistitem(l,0)
+        assert l == [None, 2, 3]


More information about the pypy-commit mailing list