Skip to content

Commit d20ff76

Browse files
committed
Use legacy Py2-2 thousands separator formatting also for Py<3.6.
1 parent 70c491b commit d20ff76

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/quicktions.pyx

+6-6
Original file line numberDiff line numberDiff line change
@@ -619,25 +619,25 @@ cdef class Fraction:
619619
cdef Py_ssize_t minimumwidth = int(match["minimumwidth"] or "0")
620620
thousands_sep = match["thousands_sep"] or ''
621621

622-
if PY_MAJOR_VERSION < 3:
623-
py2_thousands_sep, thousands_sep = thousands_sep, ''
624-
cdef Py_ssize_t first_pos # Py2-only
622+
if PY_VERSION_HEX < 0x03060000:
623+
legacy_thousands_sep, thousands_sep = thousands_sep, ''
624+
cdef Py_ssize_t first_pos # Py2/3.5-only
625625

626626
# Determine the body and sign representation.
627627
n, d = self._numerator, self._denominator
628-
if PY_MAJOR_VERSION < 3 and py2_thousands_sep:
628+
if PY_VERSION_HEX < 0x03060000 and legacy_thousands_sep:
629629
# Insert thousands separators if required.
630630
body = str(abs(n))
631631
first_pos = 1 + (len(body) - 1) % 3
632632
body = body[:first_pos] + "".join([
633-
py2_thousands_sep + body[pos : pos + 3]
633+
legacy_thousands_sep + body[pos : pos + 3]
634634
for pos in range(first_pos, len(body), 3)
635635
])
636636
if d > 1 or alternate_form:
637637
den = str(abs(d))
638638
first_pos = 1 + (len(den) - 1) % 3
639639
den = den[:first_pos] + "".join([
640-
py2_thousands_sep + den[pos: pos + 3]
640+
legacy_thousands_sep + den[pos: pos + 3]
641641
for pos in range(first_pos, len(den), 3)
642642
])
643643
body += "/" + den

0 commit comments

Comments
 (0)