[pypy-svn] r75185 - in pypy/branch/fast-forward/pypy/rlib: . test
benjamin at codespeak.net
benjamin at codespeak.net
Mon Jun 7 22:25:05 CEST 2010
Author: benjamin
Date: Mon Jun 7 22:25:03 2010
New Revision: 75185
Modified:
pypy/branch/fast-forward/pypy/rlib/rlocale.py
pypy/branch/fast-forward/pypy/rlib/test/test_rlocale.py
Log:
function for getting numeric formatting locale data
Modified: pypy/branch/fast-forward/pypy/rlib/rlocale.py
==============================================================================
--- pypy/branch/fast-forward/pypy/rlib/rlocale.py (original)
+++ pypy/branch/fast-forward/pypy/rlib/rlocale.py Mon Jun 7 22:25:03 2010
@@ -152,6 +152,14 @@
_lconv = lltype.Ptr(cConfig.lconv)
localeconv = external('localeconv', [], _lconv)
+def numeric_formatting():
+ """Specialized function to get formatting for numbers"""
+ conv = localeconv()
+ decimal_point = rffi.charp2str(conv.c_decimal_point)
+ thousands_sep = rffi.charp2str(conv.c_thousands_sep)
+ grouping = rffi.charp2str(conv.c_grouping)
+ return decimal_point, thousands_sep, grouping
+
_setlocale = external('setlocale', [rffi.INT, rffi.CCHARP], rffi.CCHARP)
def setlocale(category, locale):
Modified: pypy/branch/fast-forward/pypy/rlib/test/test_rlocale.py
==============================================================================
--- pypy/branch/fast-forward/pypy/rlib/test/test_rlocale.py (original)
+++ pypy/branch/fast-forward/pypy/rlib/test/test_rlocale.py Mon Jun 7 22:25:03 2010
@@ -4,7 +4,7 @@
import py
import locale as cpython_locale
from pypy.rlib.rlocale import setlocale, LC_ALL, LocaleError, isupper, \
- islower, isalpha, tolower, isalnum
+ islower, isalpha, tolower, isalnum, numeric_formatting
class TestLocale(object):
def setup_class(cls):
@@ -27,4 +27,9 @@
assert not isalpha(ord(" "))
assert isalnum(ord("1"))
assert tolower(ord("A")) == ord("a")
-
+
+def test_numeric_formatting():
+ dec, th, grouping = numeric_formatting()
+ assert isinstance(dec, str)
+ assert isinstance(th, str)
+ assert isinstance(grouping, str)
More information about the Pypy-commit
mailing list