[pypy-svn] r73896 - in pypy/branch/cpython-extension/pypy/module/cpyext: . test
agaynor at codespeak.net
agaynor at codespeak.net
Tue Apr 20 09:06:06 CEST 2010
Author: agaynor
Date: Tue Apr 20 09:06:04 2010
New Revision: 73896
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:
Implement PyList_Reverse
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 Tue Apr 20 09:06:04 2010
@@ -90,3 +90,11 @@
failure. This is equivalent to list.sort()."""
space.call_method(w_list, "sort")
return 0
+
+ at cpython_api([PyObject], rffi.INT_real, error=-1)
+def PyList_Reverse(space, w_list):
+ """Reverse the items of list in place. Return 0 on success, -1 on
+ failure. This is the equivalent of list.reverse()."""
+ space.call_method(w_list, "reverse")
+ return 0
+
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 Tue Apr 20 09:06:04 2010
@@ -3384,12 +3384,6 @@
require changes in your code for properly supporting 64-bit systems."""
raise NotImplementedError
- at cpython_api([PyObject], rffi.INT_real)
-def PyList_Reverse(space, list):
- """Reverse the items of list in place. Return 0 on success, -1 on
- failure. This is the equivalent of list.reverse()."""
- raise NotImplementedError
-
@cpython_api([PyObject], PyObject)
def PyList_AsTuple(space, list):
"""
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 Tue Apr 20 09:06:04 2010
@@ -37,6 +37,11 @@
l = space.newlist([space.wrap(1), space.wrap(0), space.wrap(7000)])
assert api.PyList_Sort(l) == 0
assert space.eq_w(l, space.newlist([space.wrap(0), space.wrap(1), space.wrap(7000)]))
+
+ def test_reverse(self, space, api):
+ l = space.newlist([space.wrap(3), space.wrap(2), space.wrap(1)])
+ assert api.PyList_Reverse(l) == 0
+ assert space.eq_w(l, space.newlist([space.wrap(1), space.wrap(2), space.wrap(3)]))
class AppTestListObject(AppTestCpythonExtensionBase):
def test_listobject(self):
More information about the Pypy-commit
mailing list