[pypy-svn] r73822 - in pypy/trunk/pypy: module/_locale rlib
fijal at codespeak.net
fijal at codespeak.net
Fri Apr 16 23:12:16 CEST 2010
Author: fijal
Date: Fri Apr 16 23:12:15 2010
New Revision: 73822
Modified:
pypy/trunk/pypy/module/_locale/interp_locale.py
pypy/trunk/pypy/rlib/rlocale.py
Log:
Move nl_langinfo to rlocale
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 Fri Apr 16 23:12:15 2010
@@ -172,18 +172,16 @@
strxfrm.unwrap_spec = [ObjSpace, str]
if rlocale.HAVE_LANGINFO:
- nl_item = rffi.INT
- _nl_langinfo = rlocale.external('nl_langinfo', [nl_item], rffi.CCHARP)
def nl_langinfo(space, key):
"""nl_langinfo(key) -> string
Return the value for the locale information associated with key."""
- if key in rlocale.constants.values():
- result = _nl_langinfo(rffi.cast(nl_item, key))
- return space.wrap(rffi.charp2str(result))
- raise OperationError(space.w_ValueError,
- space.wrap("unsupported langinfo constant"))
+ try:
+ return space.wrap(rlocale.nl_langinfo(key))
+ except ValueError:
+ raise OperationError(space.w_ValueError,
+ space.wrap("unsupported langinfo constant"))
nl_langinfo.unwrap_spec = [ObjSpace, int]
Modified: pypy/trunk/pypy/rlib/rlocale.py
==============================================================================
--- pypy/trunk/pypy/rlib/rlocale.py (original)
+++ pypy/trunk/pypy/rlib/rlocale.py Fri Apr 16 23:12:15 2010
@@ -163,3 +163,11 @@
islower = external('islower', [rffi.INT], rffi.INT)
tolower = external('tolower', [rffi.INT], rffi.INT)
isalnum = external('isalnum', [rffi.INT], rffi.INT)
+
+if HAVE_LANGINFO:
+ _nl_langinfo = external('nl_langinfo', [rffi.INT], rffi.CCHARP)
+
+ def nl_langinfo(key):
+ if key in constants.values():
+ return rffi.charp2str(_nl_langinfo(rffi.cast(rffi.INT, key)))
+ raise ValueError
More information about the Pypy-commit
mailing list