[pypy-svn] r75179 - in pypy/trunk/pypy/module/cpyext: . test

afa at codespeak.net afa at codespeak.net
Mon Jun 7 18:18:50 CEST 2010


Author: afa
Date: Mon Jun  7 18:18:49 2010
New Revision: 75179

Modified:
   pypy/trunk/pypy/module/cpyext/sequence.py
   pypy/trunk/pypy/module/cpyext/stubs.py
   pypy/trunk/pypy/module/cpyext/test/test_sequence.py
Log:
PySequence_List


Modified: pypy/trunk/pypy/module/cpyext/sequence.py
==============================================================================
--- pypy/trunk/pypy/module/cpyext/sequence.py	(original)
+++ pypy/trunk/pypy/module/cpyext/sequence.py	Mon Jun  7 18:18:49 2010
@@ -99,6 +99,12 @@
     return space.getitem(w_obj, space.wrap(i))
 
 @cpython_api([PyObject], PyObject)
+def PySequence_List(space, w_obj):
+    """Return a list object with the same contents as the arbitrary sequence o.  The
+    returned list is guaranteed to be new."""
+    return space.call_function(space.w_list, w_obj)
+
+ at cpython_api([PyObject], PyObject)
 def PySequence_Tuple(space, w_obj):
     """Return a tuple object with the same contents as the arbitrary sequence o or
     NULL on failure.  If o is a tuple, a new reference will be returned,

Modified: pypy/trunk/pypy/module/cpyext/stubs.py
==============================================================================
--- pypy/trunk/pypy/module/cpyext/stubs.py	(original)
+++ pypy/trunk/pypy/module/cpyext/stubs.py	Mon Jun  7 18:18:49 2010
@@ -2305,12 +2305,6 @@
     in your code for properly supporting 64-bit systems."""
     raise NotImplementedError
 
- at cpython_api([PyObject], PyObject)
-def PySequence_List(space, o):
-    """Return a list object with the same contents as the arbitrary sequence o.  The
-    returned list is guaranteed to be new."""
-    raise NotImplementedError
-
 @cpython_api([PyObject], PyObjectP, error=lltype.nullptr(PyObjectP.TO))
 def PySequence_Fast_ITEMS(space, o):
     """Return the underlying array of PyObject pointers.  Assumes that o was returned

Modified: pypy/trunk/pypy/module/cpyext/test/test_sequence.py
==============================================================================
--- pypy/trunk/pypy/module/cpyext/test/test_sequence.py	(original)
+++ pypy/trunk/pypy/module/cpyext/test/test_sequence.py	Mon Jun  7 18:18:49 2010
@@ -23,6 +23,10 @@
         assert space.type(w_seq) is space.w_tuple
         assert sorted(space.unwrap(w_seq)) == [1, 2, 3, 4]
 
+        w_seq = api.PySequence_List(w_set)
+        assert space.type(w_seq) is space.w_list
+        assert sorted(space.unwrap(w_seq)) == [1, 2, 3, 4]
+
     def test_repeat(self, space, api):
         def test(seq, count):
             w_seq = space.wrap(seq)



More information about the Pypy-commit mailing list