[pypy-svn] r73988 - in pypy/branch/cpython-extension/pypy/module/cpyext: . test

afa at codespeak.net afa at codespeak.net
Thu Apr 22 20:23:04 CEST 2010


Author: afa
Date: Thu Apr 22 20:23:02 2010
New Revision: 73988

Modified:
   pypy/branch/cpython-extension/pypy/module/cpyext/object.py
   pypy/branch/cpython-extension/pypy/module/cpyext/test/test_object.py
Log:
PyObject_Str


Modified: pypy/branch/cpython-extension/pypy/module/cpyext/object.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/object.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/object.py	Thu Apr 22 20:23:02 2010
@@ -146,6 +146,10 @@
     return from_ref(space, rffi.cast(PyObject, op)) # XXX likewise
 
 @cpython_api([PyObject], PyObject)
+def PyObject_Str(space, w_obj):
+    return space.str(w_obj)
+
+ at cpython_api([PyObject], PyObject)
 def PyObject_Repr(space, w_obj):
     """Compute a string representation of object o.  Returns the string
     representation on success, NULL on failure.  This is the equivalent of the

Modified: pypy/branch/cpython-extension/pypy/module/cpyext/test/test_object.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/test/test_object.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/test/test_object.py	Thu Apr 22 20:23:02 2010
@@ -73,6 +73,11 @@
     def test_repr(self, space, api):
         w_list = space.newlist([space.w_None, space.wrap(42)])
         assert space.str_w(api.PyObject_Repr(w_list)) == "[None, 42]"
+        assert space.str_w(api.PyObject_Repr(space.wrap("a"))) == "'a'"
+        
+        w_list = space.newlist([space.w_None, space.wrap(42)])
+        assert space.str_w(api.PyObject_Str(w_list)) == "[None, 42]"
+        assert space.str_w(api.PyObject_Str(space.wrap("a"))) == "a"
         
     def test_RichCompare(self, space, api):
         def compare(w_o1, w_o2, opid):



More information about the Pypy-commit mailing list