[pypy-svn] r74011 - in pypy/branch/cpython-extension/pypy/module/cpyext: . test
afa at codespeak.net
afa at codespeak.net
Fri Apr 23 13:32:08 CEST 2010
Author: afa
Date: Fri Apr 23 13:32:06 2010
New Revision: 74011
Modified:
pypy/branch/cpython-extension/pypy/module/cpyext/sequence.py
pypy/branch/cpython-extension/pypy/module/cpyext/test/test_sequence.py
Log:
PySequence_Concat
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 Fri Apr 23 13:32:06 2010
@@ -87,3 +87,9 @@
otherwise a tuple will be constructed with the appropriate contents. This is
equivalent to the Python expression tuple(o)."""
return space.call_function(space.w_tuple, w_obj)
+
+ at cpython_api([PyObject, PyObject], PyObject)
+def PySequence_Concat(space, w_o1, w_o2):
+ """Return the concatenation of o1 and o2 on success, and NULL on failure.
+ This is the equivalent of the Python expression o1 + o2."""
+ return space.add(w_o1, w_o2)
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 Fri Apr 23 13:32:06 2010
@@ -3,7 +3,7 @@
from pypy.module.cpyext.test.test_api import BaseApiTest
from pypy.module.cpyext import sequence
-class TestIterator(BaseApiTest):
+class TestSequence(BaseApiTest):
def test_sequence(self, space, api):
w_t = space.wrap((1, 2, 3, 4))
assert api.PySequence_Fast(w_t, "message") is w_t
@@ -22,6 +22,11 @@
assert space.type(w_seq) is space.w_tuple
assert sorted(space.unwrap(w_seq)) == [1, 2, 3, 4]
+ def test_concat(self, space, api):
+ w_t1 = space.wrap(range(4))
+ w_t2 = space.wrap(range(4, 8))
+ assert space.unwrap(api.PySequence_Concat(w_t1, w_t2)) == range(8)
+
def test_exception(self, space, api):
message = rffi.str2charp("message")
assert not api.PySequence_Fast(space.wrap(3), message)
More information about the Pypy-commit
mailing list