Skip to content

Commit

Permalink
bpo-38536: locale: Remove trailing space in formatted currency (pytho…
Browse files Browse the repository at this point in the history
  • Loading branch information
methane authored Jan 20, 2020
1 parent d8ef644 commit e96d954
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Lib/locale.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ def currency(val, symbol=True, grouping=False, international=False):
if precedes:
s = smb + (separated and ' ' or '') + s
else:
if international and smb[-1] == ' ':
smb = smb[:-1]
s = s + (separated and ' ' or '') + smb

sign_pos = conv[val<0 and 'n_sign_posn' or 'p_sign_posn']
Expand Down
3 changes: 1 addition & 2 deletions Lib/test/test_locale.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,7 @@ def test_currency(self):
euro = '\u20ac'
self._test_currency(50000, "50000,00 " + euro)
self._test_currency(50000, "50 000,00 " + euro, grouping=True)
# XXX is the trailing space a bug?
self._test_currency(50000, "50 000,00 EUR ",
self._test_currency(50000, "50 000,00 EUR",
grouping=True, international=True)


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Removes trailing space in formatted currency with `international=True` and a locale with symbol following value.
E.g. `locale.currency(12.34, international=True)` returned `'12,34 EUR '` instead of `'12,34 EUR'`.

0 comments on commit e96d954

Please sign in to comment.