mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
[3.13] gh-130664: support '_' (just as ',') in Decimal's formatting (GH-132155) (#136649)
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Docs (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Docs (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
gh-130664: support '_' (just as ',') in Decimal's formatting (GH-132155)
(cherry picked from commit e10fe81cc6
)
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
This commit is contained in:
parent
2115e71ea5
commit
2a6617de48
3 changed files with 8 additions and 1 deletions
|
@ -6083,7 +6083,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
|
||||
|
|
|
@ -1059,6 +1059,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