[Python-checkins] r71519 - in python/branches/py3k-short-float-repr: Lib/test/test_types.py Objects/stringlib/formatter.h
eric.smith
python-checkins at python.org
Sun Apr 12 17:31:57 CEST 2009
Author: eric.smith
Date: Sun Apr 12 17:31:56 2009
New Revision: 71519
Log:
Fixed localized output with floats. Changed name of constant to LT_CURRENT_LOCALE if using the current locale. Re-enabled tests.
Modified:
python/branches/py3k-short-float-repr/Lib/test/test_types.py
python/branches/py3k-short-float-repr/Objects/stringlib/formatter.h
Modified: python/branches/py3k-short-float-repr/Lib/test/test_types.py
==============================================================================
--- python/branches/py3k-short-float-repr/Lib/test/test_types.py (original)
+++ python/branches/py3k-short-float-repr/Lib/test/test_types.py Sun Apr 12 17:31:56 2009
@@ -475,8 +475,8 @@
for i in range(-10, 10):
x = 1234567890.0 * (10.0 ** i)
-# self.assertEqual(locale.format('%g', x, grouping=True), format(x, 'n'))
-# self.assertEqual(locale.format('%.10g', x, grouping=True), format(x, '.10n'))
+ self.assertEqual(locale.format('%g', x, grouping=True), format(x, 'n'))
+ self.assertEqual(locale.format('%.10g', x, grouping=True), format(x, '.10n'))
@run_with_locale('LC_NUMERIC', 'en_US.UTF8')
def test_int__format__locale(self):
Modified: python/branches/py3k-short-float-repr/Objects/stringlib/formatter.h
==============================================================================
--- python/branches/py3k-short-float-repr/Objects/stringlib/formatter.h (original)
+++ python/branches/py3k-short-float-repr/Objects/stringlib/formatter.h Sun Apr 12 17:31:56 2009
@@ -245,7 +245,7 @@
/************************************************************************/
/* Locale type codes. */
-#define LT_USE_LOCALE 0
+#define LT_CURRENT_LOCALE 0
#define LT_DEFAULT_LOCALE 1
#define LT_NO_LOCALE 2
@@ -516,14 +516,14 @@
/* Find the decimal point character(s?), thousands_separator(s?), and
grouping description, either for the current locale if type is
- LT_USE_LOCALE, a hard-coded locale if LT_DEFAULT_LOCALE, or none if
- LT_NO_LOCALE. */
+ LT_CURRENT_LOCALE, a hard-coded locale if LT_DEFAULT_LOCALE, or
+ none if LT_NO_LOCALE. */
static void
get_locale_info(int type, LocaleInfo *locale_info)
{
locale_info->type = type;
switch (type) {
- case LT_USE_LOCALE: {
+ case LT_CURRENT_LOCALE: {
struct lconv *locale_data = localeconv();
locale_info->decimal_point = locale_data->decimal_point;
locale_info->thousands_sep = locale_data->thousands_sep;
@@ -684,7 +684,6 @@
goto done;
}
-
/* special case for character formatting */
if (format->type == 'c') {
/* error to specify a sign */
@@ -797,8 +796,9 @@
}
/* Determine the grouping, separator, and decimal point, if any. */
- get_locale_info(format->type == 'n' ? LT_USE_LOCALE :
- (format->thousands_separators ? LT_DEFAULT_LOCALE :
+ get_locale_info(format->type == 'n' ? LT_CURRENT_LOCALE :
+ (format->thousands_separators ?
+ LT_DEFAULT_LOCALE :
LT_NO_LOCALE),
&locale);
@@ -944,8 +944,9 @@
parse_number(p, n_digits, &n_remainder, &has_decimal);
/* Determine the grouping, separator, and decimal point, if any. */
- get_locale_info(type == 'n' ? LT_USE_LOCALE :
- (format->thousands_separators ? LT_DEFAULT_LOCALE :
+ get_locale_info(format->type == 'n' ? LT_CURRENT_LOCALE :
+ (format->thousands_separators ?
+ LT_DEFAULT_LOCALE :
LT_NO_LOCALE),
&locale);
More information about the Python-checkins
mailing list