Message 239498 - Python tracker (original) (raw)
I think that Decimal is not needed for Fraction.format (and I'm not sure that issue23602v4.patch is correct). The correct way to format Fraction as fixed-precision decimal is to use Fraction.round() or similar algorithm. The implementation can look like:
f = self.__round__(prec)
i = int(f)
return '%d.%0*d' % (i, prec, abs(f - i) * 10**prec)