Message152418
With the changeset 056f5cc8885d, format(1234, 'n') fails in a locale using a non-ASCII thousands separator. Patch showing the problem:
diff --git a/Lib/test/test_format.py b/Lib/test/test_format.py
--- a/Lib/test/test_format.py
+++ b/Lib/test/test_format.py
@@ -1,4 +1,5 @@
from test.support import verbose, TestFailed
+import locale
import sys
import test.support as support
import unittest
@@ -282,6 +283,19 @@ class FormatTest(unittest.TestCase):
self.assertEqual(format(1+2j, "\u2007^8"), "\u2007(1+2j)\u2007")
self.assertEqual(format(0j, "\u2007^4"), "\u20070j\u2007")
+ def test_locale(self):
+ try:
+ oldloc = locale.setlocale(locale.LC_ALL, '')
+ except locale.Error as err:
+ self.skipTest("Cannot set locale: {}".format(err))
+ try:
+ sep = locale.localeconv()['thousands_sep']
+ self.assertEqual(format(123456789, "n"),
+ sep.join(('123', '456', '789')))
+ finally:
+ locale.setlocale(locale.LC_ALL, oldloc)
+
+
def test_main():
support.run_unittest(FormatTest) |
|
Date |
User |
Action |
Args |
2012-02-01 00:03:31 | vstinner | set | recipients:
+ vstinner, loewis, mark.dickinson, eric.smith, benjamin.peterson, ezio.melotti, skrah, python-dev, Jim.Jewett |
2012-02-01 00:03:31 | vstinner | set | messageid: <1328054611.72.0.995471560037.issue13706@psf.upfronthosting.co.za> |
2012-02-01 00:03:31 | vstinner | link | issue13706 messages |
2012-02-01 00:03:30 | vstinner | create | |
|