[New-bugs-announce] [issue4799] handling inf/nan in '%f'

Cournapeau David report at bugs.python.org
Thu Jan 1 08:52:47 CET 2009

New submission from Cournapeau David <david at ar.media.kyoto-u.ac.jp>:

On windows, with python 2.6,  s = '%s' % float('inf') is 'inf', but s =
'%f' % float('inf') is equal to '1.#INF'.

This patch fixes the inconsistency, by using the code from floatobject.f
format_float into stringobject.c formatfloat. I think it would be better
to use the same underlying implementations for both functions, but it is
not so easy, because format_float cannot fail (return void), whereas
formatfloat can (return error code).

components: Interpreter Core
files: nan.patch
keywords: patch
messages: 78693
nosy: cdavid
severity: normal
status: open
title: handling inf/nan in '%f'
versions: Python 2.6
Added file: http://bugs.python.org/file12518/nan.patch

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list