def format_float(self, w_value, char): space = self.space x = space.float_w(maybe_float(space, w_value)) if isnan(x): r = 'nan' elif isinf(x): r = 'inf' else: prec = self.prec if prec < 0: prec = 6 if char in 'fF' and x/1e25 > 1e25: char = chr(ord(char) + 1) # 'f' => 'g' try: r = formatd_overflow(self.f_alt, prec, char, x) except OverflowError: raise OperationError(space.w_OverflowError, space.wrap( "formatted float is too long (precision too large?)")) self.std_wp_number(r)
def func(x): # Test the %F format, which is not supported by # the Microsoft's msvcrt library. return formatd_overflow(0, 4, 'F', x)