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

afa at codespeak.net afa at codespeak.net
Tue Apr 6 18:49:43 CEST 2010


Author: afa
Date: Tue Apr  6 18:49:41 2010
New Revision: 73462

Modified:
   pypy/branch/cpython-extension/pypy/module/cpyext/api.py
   pypy/branch/cpython-extension/pypy/module/cpyext/test/test_unicodeobject.py
   pypy/branch/cpython-extension/pypy/module/cpyext/unicodeobject.py
Log:
Run the tests, and fix.
At RPython level, Py_UNICODE is a single unicode char.


Modified: pypy/branch/cpython-extension/pypy/module/cpyext/api.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/api.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/api.py	Tue Apr  6 18:49:41 2010
@@ -169,10 +169,12 @@
                             arg = input_arg
                     elif ARG is PyObject and is_wrapped:
                         # convert to a wrapped object
-                        if input_arg and rffi._isllptr(input_arg):
-                            arg = from_ref(space, input_arg)
-                        else:
+                        if input_arg is None:
+                            arg = input_arg
+                        elif isinstance(input_arg, W_Root):
                             arg = input_arg
+                        else:
+                            arg = from_ref(space, input_arg)
                     else:
                         arg = input_arg
                     newargs += (arg, )

Modified: pypy/branch/cpython-extension/pypy/module/cpyext/test/test_unicodeobject.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/test/test_unicodeobject.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/test/test_unicodeobject.py	Tue Apr  6 18:49:41 2010
@@ -22,23 +22,23 @@
                      0x2009, 0x200a,
                      #0x200b is in Other_Default_Ignorable_Code_Point in 4.1.0
                      0x2028, 0x2029, 0x202f, 0x205f, 0x3000]:
-            assert api.Py_UNICODE_ISSPACE(char)
-        assert not api.Py_UNICODE_ISSPACE(ord(u'a'))
+            assert api.Py_UNICODE_ISSPACE(unichr(char))
+        assert not api.Py_UNICODE_ISSPACE(u'a')
 
-        assert api.Py_UNICODE_ISDECIMAL(ord(u'\u0660'))
-        assert not api.Py_UNICODE_ISDECIMAL(ord(u'a'))
+        assert api.Py_UNICODE_ISDECIMAL(u'\u0660')
+        assert not api.Py_UNICODE_ISDECIMAL(u'a')
 
         for char in [0x0a, 0x0d, 0x1c, 0x1d, 0x1e, 0x85, 0x2028, 0x2029]:
-            assert api.Py_UNICODE_ISLINEBREAK(char)
+            assert api.Py_UNICODE_ISLINEBREAK(unichr(char))
 
-        assert api.Py_UNICODE_ISLOWER(ord(u'ä'))
-        assert not api.Py_UNICODE_ISUPPER(ord(u'ä'))
-        assert api.Py_UNICODE_ISLOWER(ord(u'a'))
-        assert not api.Py_UNICODE_ISUPPER(ord(u'a'))
-        assert not api.Py_UNICODE_ISLOWER(ord(u'Ä'))
-        assert api.Py_UNICODE_ISUPPER(ord(u'Ä'))
+        assert api.Py_UNICODE_ISLOWER(u'ä')
+        assert not api.Py_UNICODE_ISUPPER(u'ä')
+        assert api.Py_UNICODE_ISLOWER(u'a')
+        assert not api.Py_UNICODE_ISUPPER(u'a')
+        assert not api.Py_UNICODE_ISLOWER(u'Ä')
+        assert api.Py_UNICODE_ISUPPER(u'Ä')
 
     def test_TOLOWER(self, space, api):
-        assert api.Py_UNICODE_TOLOWER(ord(u'ä')) == ord(u'ä')
-        assert api.Py_UNICODE_TOLOWER(ord(u'Ä')) == ord(u'ä')
+        assert api.Py_UNICODE_TOLOWER(u'ä') == u'ä'
+        assert api.Py_UNICODE_TOLOWER(u'Ä') == u'ä'
 

Modified: pypy/branch/cpython-extension/pypy/module/cpyext/unicodeobject.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/unicodeobject.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/unicodeobject.py	Tue Apr  6 18:49:41 2010
@@ -52,7 +52,7 @@
 @cpython_api([Py_UNICODE], Py_UNICODE, error=CANNOT_FAIL)
 def Py_UNICODE_TOLOWER(space, ch):
     """Return the character ch converted to lower case."""
-    return unicodedb.tolower(ord(ch))
+    return unichr(unicodedb.tolower(ord(ch)))
 
 @cpython_api([PyObject], rffi.CCHARP, error=CANNOT_FAIL)
 def PyUnicode_AS_DATA(space, ref):



More information about the Pypy-commit mailing list