mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-130664: support '_' (just as ',') in Decimal's formatting (#132155)
This commit is contained in:
parent
c66ffcf8e3
commit
e10fe81cc6
3 changed files with 8 additions and 1 deletions
|
@ -6098,7 +6098,7 @@ _parse_format_specifier_regex = re.compile(r"""\A
|
|||
(?P<alt>\#)?
|
||||
(?P<zeropad>0)?
|
||||
(?P<minimumwidth>(?!0)\d+)?
|
||||
(?P<thousands_sep>,)?
|
||||
(?P<thousands_sep>[,_])?
|
||||
(?:\.(?P<precision>0|(?!0)\d+))?
|
||||
(?P<type>[eEfFgGn%])?
|
||||
\Z
|
||||
|
|
|
@ -1083,6 +1083,11 @@ class FormatTest:
|
|||
(',%', '123.456789', '12,345.6789%'),
|
||||
(',e', '123456', '1.23456e+5'),
|
||||
(',E', '123456', '1.23456E+5'),
|
||||
# ... with '_' instead
|
||||
('_', '1234567', '1_234_567'),
|
||||
('07_', '1234.56', '1_234.56'),
|
||||
('_', '1.23456789', '1.23456789'),
|
||||
('_%', '123.456789', '12_345.6789%'),
|
||||
|
||||
# negative zero: default behavior
|
||||
('.1f', '-0', '-0.0'),
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Support the ``'_'`` digit separator in formatting of the integral part of
|
||||
:class:`~decimal.Decimal`'s. Patch by Sergey B Kirpichev.
|
Loading…
Add table
Add a link
Reference in a new issue