]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-38536: locale: Remove trailing space in formatted currency (GH-16864)
authorInada Naoki <songofacandy@gmail.com>
Mon, 20 Jan 2020 03:45:50 +0000 (12:45 +0900)
committerGitHub <noreply@github.com>
Mon, 20 Jan 2020 03:45:50 +0000 (12:45 +0900)
Lib/locale.py
Lib/test/test_locale.py
Misc/NEWS.d/next/Library/2019-10-21-20-24-51.bpo-38536.beZ0Sk.rst [new file with mode: 0644]

index dd8a08524a018e8ff34f10a8d96b6cbbc171b063..1a4e9f694f30967f9fd482c835923c92fa0f7cd1 100644 (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']
index c5d8e269d631834d67e54189269ee2d1c2e7af2e..2863d200e25c2eb97407f462f79790bbc356e0ae 100644 (file)
@@ -334,8 +334,7 @@ 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 ",
+        self._test_currency(50000, "50 000,00 EUR",
             grouping=True, international=True)
 
 
diff --git a/Misc/NEWS.d/next/Library/2019-10-21-20-24-51.bpo-38536.beZ0Sk.rst b/Misc/NEWS.d/next/Library/2019-10-21-20-24-51.bpo-38536.beZ0Sk.rst
new file mode 100644 (file)
index 0000000..147d181
--- /dev/null
@@ -0,0 +1,2 @@
+Removes trailing space in formatted currency with `international=True` and a locale with symbol following value.\r
+E.g. `locale.currency(12.34, international=True)` returned `'12,34 EUR '` instead of `'12,34 EUR'`.\r