[pypy-svn] r73359 - in pypy/branch/cpython-extension/pypy/module/cpyext: . test
agaynor at codespeak.net
agaynor at codespeak.net
Sun Apr 4 19:12:01 CEST 2010
Author: agaynor
Date: Sun Apr 4 19:11:59 2010
New Revision: 73359
Modified:
pypy/branch/cpython-extension/pypy/module/cpyext/listobject.py
pypy/branch/cpython-extension/pypy/module/cpyext/sequence.py
pypy/branch/cpython-extension/pypy/module/cpyext/test/test_sequence.py
Log:
A few fixes to the methods I implemented.
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 19:11:59 2010
@@ -52,4 +52,5 @@
This macro returned an int. This might require changes in your
code for properly supporting 64-bit systems."""
+ assert isinstance(w_list, W_ListObject)
return len(w_list.wrappeditems)
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/sequence.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/sequence.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/sequence.py Sun Apr 4 19:11:59 2010
@@ -45,10 +45,10 @@
return len(w_obj.wrappeditems)
@cpython_api([PyObject, Py_ssize_t, Py_ssize_t], PyObject)
-def PySequence_GetSlice(space, w_obj, w_start, w_end):
+def PySequence_GetSlice(space, w_obj, start, end):
"""Return the slice of sequence object o between i1 and i2, or NULL on
failure. This is the equivalent of the Python expression o[i1:i2].
This function used an int type for i1 and i2. This might
require changes in your code for properly supporting 64-bit systems."""
- return space.getslice(w_obj, w_start, w_end)
+ return space.getslice(w_obj, space.wrap(start), space.wrap(end))
Modified: pypy/branch/cpython-extension/pypy/module/cpyext/test/test_sequence.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/test/test_sequence.py (original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/test/test_sequence.py Sun Apr 4 19:11:59 2010
@@ -32,5 +32,5 @@
def test_get_slice(self, space, api):
w_t = space.wrap((1, 2, 3, 4, 5))
- assert space.unwrap(api.PySequence_GetSlice(w_t, space.wrap(2), space.wrap(4))) == (3, 4)
- assert space.unwrap(api.PySequence_GetSlice(w_t, space.wrap(1), space.wrap(-1))) == (2, 3, 4)
+ assert space.unwrap(api.PySequence_GetSlice(w_t, 2, 4)) == (3, 4)
+ assert space.unwrap(api.PySequence_GetSlice(w_t, 1, -1)) == (2, 3, 4)
More information about the Pypy-commit
mailing list