[3.14] gh-130662: Accept leading zeros in precision/width for Decimal… · python/cpython@f87578f · GitHub
Skip to content

Commit f87578f

Browse files
miss-islingtonskirpichevpicnixz
authored
[3.14] gh-130662: Accept leading zeros in precision/width for Decimal's formatting (GH-132549) (#136362)
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
1 parent b2a2f03 commit f87578f

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

Lib/_pydecimal.py

Lines changed: 2 additions & 2 deletions

Lib/test/test_decimal.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,7 @@ def test_formatting(self):
982982
('.0f', '0e-2', '0'),
983983
('.0f', '3.14159265', '3'),
984984
('.1f', '3.14159265', '3.1'),
985+
('.01f', '3.14159265', '3.1'), # leading zero in precision
985986
('.4f', '3.14159265', '3.1416'),
986987
('.6f', '3.14159265', '3.141593'),
987988
('.7f', '3.14159265', '3.1415926'), # round-half-even!
@@ -1067,6 +1068,7 @@ def test_formatting(self):
10671068
('8,', '123456', ' 123,456'),
10681069
('08,', '123456', '0,123,456'), # special case: extra 0 needed
10691070
('+08,', '123456', '+123,456'), # but not if there's a sign
1071+
('008,', '123456', '0,123,456'), # leading zero in width
10701072
(' 08,', '123456', ' 123,456'),
10711073
('08,', '-123456', '-123,456'),
10721074
('+09,', '123456', '+0,123,456'),
Lines changed: 3 additions & 0 deletions

0 commit comments

Comments
 (0)