Skip to content

Commit c30e36b

Browse files
committed
Thousands separator in formatting was handled differently than for floats etc.
See python/cpython#131067
1 parent d75678c commit c30e36b

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/quicktions.pyx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,9 @@ cdef class Fraction:
994994
cdef bint trim_point = not alternate_form
995995
exponent_indicator = "E" if presentation_type in u"EFG" else "e"
996996

997+
if align == '=' and fill == '0':
998+
zeropad = True
999+
9971000
cdef bint negative, scientific
9981001
cdef Py_ssize_t exponent, figures
9991002

src/test_fractions.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,11 +1688,8 @@ def test_format_f_presentation_type(self):
16881688
(F('-1234.5678'), '08,.0f', '-001,235'),
16891689
(F('-1234.5678'), '09,.0f', '-0,001,235'),
16901690
# Corner-case - zero-padding specified through fill and align
1691-
# instead of the zero-pad character - in this case, treat '0' as a
1692-
# regular fill character and don't attempt to insert commas into
1693-
# the filled portion. This differs from the int and float
1694-
# behaviour.
1695-
(F('1234.5678'), '0=12,.2f', '00001,234.57'),
1691+
# instead of the zero-pad character.
1692+
(F('1234.5678'), '0=12,.2f', '0,001,234.57'),
16961693
# Corner case where it's not clear whether the '0' indicates zero
16971694
# padding or gives the minimum width, but there's still an obvious
16981695
# answer to give. We want this to work in case the minimum width

0 commit comments

Comments
 (0)