[pypy-svn] r73356 - in pypy/branch/cpython-extension/pypy/module/cpyext: . test
agaynor at codespeak.net
agaynor at codespeak.net
Sun Apr 4 16:51:53 CEST 2010
Author: agaynor
Date: Sun Apr 4 16:51:51 2010
New Revision: 73356
Modified:
pypy/branch/cpython-extension/pypy/module/cpyext/listobject.py
pypy/branch/cpython-extension/pypy/module/cpyext/stubs.py
pypy/branch/cpython-extension/pypy/module/cpyext/test/test_listobject.py
Log:
Implemented PyList_GET_SIZE
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/listobject.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/listobject.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/listobject.py Sun Apr 4 16:51:51 2010
@@ -45,3 +45,11 @@
PyErr_BadInternalCall(space)
w_list.append(w_item)
return 0
+
+ at cpython_api([PyObject], Py_ssize_t, error=CANNOT_FAIL)
+def PyList_GET_SIZE(space, w_list):
+ """Macro form of PyList_Size() without error checking.
+
+ This macro returned an int. This might require changes in your
+ code for properly supporting 64-bit systems."""
+ return len(w_list.wrappeditems)
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/stubs.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/stubs.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/stubs.py Sun Apr 4 16:51:51 2010
@@ -3329,14 +3329,6 @@
your code for properly supporting 64-bit systems."""
raise NotImplementedError
- at cpython_api([PyObject], Py_ssize_t)
-def PyList_GET_SIZE(space, list):
- """Macro form of PyList_Size() without error checking.
-
- This macro returned an int. This might require changes in your
- code for properly supporting 64-bit systems."""
- raise NotImplementedError
-
@cpython_api([PyObject, Py_ssize_t], PyObject, borrowed=True)
def PyList_GetItem(space, list, index):
"""Return the object at position pos in the list pointed to by p. The
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/test/test_listobject.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/test/test_listobject.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/test/test_listobject.py Sun Apr 4 16:51:51 2010
@@ -19,6 +19,12 @@
assert not api.PyList_Check(space.newtuple([]))
assert not api.PyList_CheckExact(space.newtuple([]))
+
+ def test_get_size(self, space, api):
+ l = api.PyList_New(0)
+ assert api.PyList_GET_SIZE(l) == 0
+ api.PyList_Append(l, space.wrap(3))
+ assert api.PyList_GET_SIZE(l) == 1
class AppTestListObject(AppTestCpythonExtensionBase):
def test_listobject(self):
More information about the Pypy-commit
mailing list