From 43b05afdf51d19caadafd27562dafc4a85f0b67d Mon Sep 17 00:00:00 2001 From: Alessandro Gatti Date: Mon, 23 Sep 2024 18:07:47 +0200 Subject: py/mpz: Skip separators when running out of digits to print. This commit fixes the addition of a stray separator before the number when printing an MPZ-backed integer and the first group is three digits long. This fixes #8984. Signed-off-by: Alessandro Gatti --- tests/basics/string_format_intbig.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tests/basics/string_format_intbig.py (limited to 'tests/basics/string_format_intbig.py') diff --git a/tests/basics/string_format_intbig.py b/tests/basics/string_format_intbig.py new file mode 100644 index 000000000..a36c36752 --- /dev/null +++ b/tests/basics/string_format_intbig.py @@ -0,0 +1,15 @@ +# basic functionality test for {} format string using large integers + + +def test(fmt, *args): + print("{:8s}".format(fmt) + ">" + fmt.format(*args) + "<") + + +# Separator formatter + +test("{:,}", 123_456_789_012_345_678_901_234_567) +test("{:,}", 23_456_789_012_345_678_901_234_567) +test("{:,}", 3_456_789_012_345_678_901_234_567) +test("{:,}", -123_456_789_012_345_678_901_234_567) +test("{:,}", -23_456_789_012_345_678_901_234_567) +test("{:,}", -3_456_789_012_345_678_901_234_567) -- cgit v1.2.3