[pypy-svn] r74192 - in pypy/branch/cpython-extension/pypy/module/cpyext: . test
afa at codespeak.net
afa at codespeak.net
Wed Apr 28 19:36:18 CEST 2010
Author: afa
Date: Wed Apr 28 19:36:16 2010
New Revision: 74192
Modified:
pypy/branch/cpython-extension/pypy/module/cpyext/object.py
pypy/branch/cpython-extension/pypy/module/cpyext/stubs.py
pypy/branch/cpython-extension/pypy/module/cpyext/test/test_object.py
Log:
PyObject_Unicode
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 Wed Apr 28 19:36:16 2010
@@ -188,6 +188,14 @@
by reverse quotes."""
return space.repr(w_obj)
+ at cpython_api([PyObject], PyObject)
+def PyObject_Unicode(space, w_obj):
+ """Compute a Unicode string representation of object o. Returns the Unicode
+ string representation on success, NULL on failure. This is the equivalent of
+ the Python expression unicode(o). Called by the unicode() built-in
+ function."""
+ return space.call_function(space.w_unicode, w_obj)
+
@cpython_api([PyObject, PyObject], rffi.INT_real, error=-1)
def PyObject_Compare(space, w_o1, w_o2):
"""
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 Wed Apr 28 19:36:16 2010
@@ -2978,18 +2978,6 @@
for PyObject_Str()."""
raise NotImplementedError
- at cpython_api([PyObject], PyObject)
-def PyObject_Unicode(space, o):
- """
-
-
-
- Compute a Unicode string representation of object o. Returns the Unicode
- string representation on success, NULL on failure. This is the equivalent of
- the Python expression unicode(o). Called by the unicode() built-in
- function."""
- raise NotImplementedError
-
@cpython_api([PyObject, rffi.CCHARP, ], PyObject)
def PyObject_CallFunction(space, callable, format, ):
"""
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 Wed Apr 28 19:36:16 2010
@@ -172,3 +172,9 @@
assert api.PyObject_Compare(space.wrap(42), space.wrap(72)) == -1
assert api.PyObject_Compare(space.wrap(72), space.wrap(42)) == 1
assert api.PyObject_Compare(space.wrap("a"), space.wrap("a")) == 0
+
+ def test_unicode(self, space, api):
+ assert space.unwrap(api.PyObject_Unicode(space.wrap([]))) == u"[]"
+ assert space.unwrap(api.PyObject_Unicode(space.wrap("e"))) == u"e"
+ assert api.PyObject_Unicode(space.wrap("\xe9")) is None
+ api.PyErr_Clear()
More information about the Pypy-commit
mailing list