bpo-38536: locale: Remove trailing space in formatted currency (GH-16864)

This commit is contained in:
Inada Naoki 2020-01-20 12:45:50 +09:00 committed by GitHub
parent d8ef64422a
commit e96d954527
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 2 deletions

View File

@ -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']

View File

@ -334,7 +334,6 @@ class TestFrFRNumberFormatting(FrFRCookedTest, BaseFormattingTest):
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",
grouping=True, international=True)

View File

@ -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'`.