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 edlm10
Recipients edlm10
Date 2007-09-30.17:17:47
SpamBayes Score 0.27389166
Marked as misclassified No
Message-id <1191172668.69.0.513518274707.issue1222@psf.upfronthosting.co.za>
In-reply-to
Content
locale.format function delete spaces in result which is a problem when
thousand separator is space (in French for example).

The problem seems in the code below (extract from locale.py):

145     while seps:
146         # If the number was formatted for a specific width, then it
147         # might have been filled with spaces to the left or right. If
148         # so, kill as much spaces as there where separators.
149         # Leading zeroes as fillers are not yet dealt with, as it is
150         # not clear how they should interact with grouping.
151         sp = result.find(" ")
152         if sp==-1:break
153         result = result[:sp]+result[sp+1:]
154         seps -= 1

Example :

>>> import locale
>>> locale.setlocale(locale.LC_NUMERIC)
'C'
>>> locale.setlocale(locale.LC_NUMERIC, "fr_FR.UTF-8")
'fr_FR.UTF-8'
>>> locale.format("%.2f", 12345.67, True)
'12345,67'

The correct result is '12 345,67' not '12345,67'

and if I call

>>> locale.format("%9.2f", 12345.67, True)
'12 345,67'

the result is correct

Is this behavior correct or a bug?
History
Date User Action Args
2007-09-30 17:17:49edlm10setspambayes_score: 0.273892 -> 0.27389166
recipients: + edlm10
2007-09-30 17:17:48edlm10setspambayes_score: 0.273892 -> 0.273892
messageid: <1191172668.69.0.513518274707.issue1222@psf.upfronthosting.co.za>
2007-09-30 17:17:48edlm10linkissue1222 messages
2007-09-30 17:17:47edlm10create