This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients Jim.Jewett, benjamin.peterson, eric.smith, ezio.melotti, loewis, mark.dickinson, python-dev, skrah, vstinner
Date 2012-02-01.00:03:30
SpamBayes Score 0.00024291013
Marked as misclassified No
Message-id <1328054611.72.0.995471560037.issue13706@psf.upfronthosting.co.za>
In-reply-to
Content
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)
History
Date User Action Args
2012-02-01 00:03:31vstinnersetrecipients: + vstinner, loewis, mark.dickinson, eric.smith, benjamin.peterson, ezio.melotti, skrah, python-dev, Jim.Jewett
2012-02-01 00:03:31vstinnersetmessageid: <1328054611.72.0.995471560037.issue13706@psf.upfronthosting.co.za>
2012-02-01 00:03:31vstinnerlinkissue13706 messages
2012-02-01 00:03:30vstinnercreate