[Python-Dev] PEP 3101: floats format 'f' and 'F' (original) (raw)

Thomas Heller theller at ctypes.org
Thu Jul 17 21:02:21 CEST 2008


Guido van Rossum schrieb:

On Thu, Jul 17, 2008 at 9:25 AM, Raymond Hettinger <python at rcn.com> wrote:

From: "Eric Smith" <eric+python-dev at trueblade.com>

I have this ready for checkin (with docs and tests). I'd like to get it in for this beta, since it does involved changed behavior, no matter how small ('1e+100' becomes '1E+100' with '%F'). But it relies on the platform's vsnprintf to do the right thing with 'F', so I'm worried about breakages on platforms I don't have access to. Resolving those issues might take a few days. Any advice on checking this in now, or waiting until after this beta is released? I recommend doing it after the release. It's unlikely to be exercised much by the beta users so there's no real advantage. If you wait until afterwards, then there is time to let the buildbots have a go at it and reveal any cross-platform issues. Besides, Barry said something about getting meaner. Would hate to find out what he meant the hard way ;-) I'd advise the opposite -- check it in now. It's not going to break anything, and if it is, let's find out sooner rather than later.

Before we get old waiting for the windows buildbots, here how test_format fails now (on XP SP2 x86, trunk rev 65072:

c:\svn\trunk\PCbuild>.\python_d -E -tt ../lib/test/regrtest.py test_format test_format test test_format produced unexpected output:


'%F' % (1.0,) == '' != '1.000000' u'%F' % (1.0,) == u'' != '1.000000' '%f' % (nan,) == '-1.#IND00' != 'nan' u'%f' % (nan,) == u'-1.#IND00' != 'nan' '%F' % (nan,) == '' != 'NAN' u'%F' % (nan,) == u'' != 'NAN' '%f' % (inf,) == '1.#INF' != 'inf' u'%f' % (inf,) == u'1.#INF' != 'inf' '%F' % (inf,) == '1.#INF' != 'INF' u'%F' % (inf,) == u'1.#INF' != 'INF'


1 test failed: test_format [23521 refs]

c:\svn\trunk\PCbuild>

Windows vsnprintf does not support '%F' at all, and '%f' does not behave as expected with nan and inf.

-- Thanks, Thomas



More information about the Python-Dev mailing list