[pypy-svn] r61903 - in pypy/trunk/pypy/module/_locale: . test
getxsick at codespeak.net
getxsick at codespeak.net
Sun Feb 15 00:47:27 CET 2009
Author: getxsick
Date: Sun Feb 15 00:47:25 2009
New Revision: 61903
Modified:
pypy/trunk/pypy/module/_locale/interp_locale.py
pypy/trunk/pypy/module/_locale/test/test_locale.py
Log:
(jlg, getxsick) unicode arguments for strcoll() supported
Modified: pypy/trunk/pypy/module/_locale/interp_locale.py
==============================================================================
--- pypy/trunk/pypy/module/_locale/interp_locale.py (original)
+++ pypy/trunk/pypy/module/_locale/interp_locale.py Sun Feb 15 00:47:25 2009
@@ -164,7 +164,7 @@
localeconv.unwrap_spec = [ObjSpace]
_strcoll = external('strcoll', [rffi.CCHARP, rffi.CCHARP], rffi.INT)
-_wcscoll = external('wcscoll', [rffi.WCHAR_TP, rffi.WCHAR_TP], rffi.INT)
+_wcscoll = external('wcscoll', [rffi.CWCHARP, rffi.CWCHARP], rffi.INT)
def strcoll(space, w_s1, w_s2):
"string,string -> int. Compares two strings according to the locale."
@@ -182,13 +182,10 @@
s1, s2 = space.unicode_w(w_s1), space.unicode_w(w_s2)
- # XXX rffi.unicode2wcharp needed
- raise OperationError(space.w_NotImplementedError,
- space.wrap("PyPy specific - not implemented for unicode arguments"))
-
- #s1_c = rffi.str2charp(s1)
- #s2_c = rffi.str2charp(s2)
- #return space.wrap(_wcscoll(s1_c, s2_c))
+ s1_c = rffi.unicode2wcharp(s1)
+ s2_c = rffi.unicode2wcharp(s2)
+ result = _wcscoll(s1_c, s2_c)
+ return space.wrap(result)
strcoll.unwrap_spec = [ObjSpace, W_Root, W_Root]
Modified: pypy/trunk/pypy/module/_locale/test/test_locale.py
==============================================================================
--- pypy/trunk/pypy/module/_locale/test/test_locale.py (original)
+++ pypy/trunk/pypy/module/_locale/test/test_locale.py Sun Feb 15 00:47:25 2009
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
from pypy.conftest import gettestobjspace
import sys
@@ -97,9 +98,9 @@
_locale.setlocale(_locale.LC_ALL, "pl_PL.UTF-8")
assert _locale.strcoll("a", "b") < 0
- assert _locale.strcoll('\xc4\x85', "b") < 0
+ assert _locale.strcoll("ą", "b") < 0
- assert _locale.strcoll('\xc4\x87', "b") > 0
+ assert _locale.strcoll("ć", "b") > 0
assert _locale.strcoll("c", "b") > 0
assert _locale.strcoll("b", "b") == 0
@@ -108,13 +109,12 @@
raises(TypeError, _locale.strcoll, "b", 1)
def test_strcoll_unicode(self):
- skip("not implemented, rffi.unicode2wcharp needed")
import _locale
_locale.setlocale(_locale.LC_ALL, "pl_PL.UTF-8")
assert _locale.strcoll(u"b", u"b") == 0
- assert _locale.strcoll(u'\xc4\x85', "b") < 0
- assert _locale.strcoll(u'\xc4\x87', "b") > 0
+ assert _locale.strcoll(u"a", u"b") < 0
+ assert _locale.strcoll(u"b", u"a") > 0
raises(TypeError, _locale.strcoll, 1, u"b")
raises(TypeError, _locale.strcoll, u"b", 1)
More information about the Pypy-commit
mailing list