[pypy-svn] r61702 - pypy/trunk/pypy/module/unicodedata

afa at codespeak.net afa at codespeak.net
Tue Feb 10 23:42:40 CET 2009


Author: afa
Date: Tue Feb 10 23:42:37 2009
New Revision: 61702

Modified:
   pypy/trunk/pypy/module/unicodedata/interp_ucd.py
Log:
Revert this change in unicodedata, because the functions did not check anymore
that the string is composed of a single unicode char, and broke tests.


Modified: pypy/trunk/pypy/module/unicodedata/interp_ucd.py
==============================================================================
--- pypy/trunk/pypy/module/unicodedata/interp_ucd.py	(original)
+++ pypy/trunk/pypy/module/unicodedata/interp_ucd.py	Tue Feb 10 23:42:37 2009
@@ -21,9 +21,11 @@
 SCount = (LCount*NCount)
 
 def unichr_to_code_w(space, w_unichr):
-    from pypy.rlib.runicode import ORD
-    u = space.unicode_w(w_unichr)
-    return ORD(u)
+    if not space.is_true(space.isinstance(w_unichr, space.w_unicode)):
+        raise OperationError(space.w_TypeError, space.wrap('argument 1 must be unicode'))
+    if not space.int_w(space.len(w_unichr)) == 1:
+        raise OperationError(space.w_TypeError, space.wrap('need a single Unicode character as parameter'))
+    return space.int_w(space.ord(w_unichr))
 
 class UCD(Wrappable):
     def __init__(self, unicodedb):



More information about the Pypy-commit mailing list