[issue1600] str.format() produces different output on different platforms (Py30a2)

Mark Summerfield report at bugs.python.org
Sat Dec 15 22:27:29 CET 2007


Mark Summerfield added the comment:

On 2007-12-15, Christian Heimes wrote:
> Christian Heimes added the comment:
>
> Guido is right. On Linux the system's sprintf() family prints %e, %g and
> %f with two or three digits while Windows always uses three digits:
>
> Linux
> >>> "%e" % 1e1
> '1.000000e+01'
> >>> "%e" % 1e10
> '1.000000e+10'
> >>> "%e" % 1e100
> '1.000000e+100'
>
> Windows
> >>> "%e" % 1e1
> '1.000000e+001'
> >>> "%e" % 1e10
> '1.000000e+010'
> >>> "%e" % 1e100
> '1.000000e+100'
>
> The output could be changed in any of the functions:
> Objects/floatobject.h:format_double()
> Python/pystrtod.c:PyOS_ascii_formatd()
> Python/mysnprint.c:PyOS_snprintf()

It seems to me that Python should provide consistent results across
platforms wherever possible and that this is a gratuitous inconsistency
that makes cross-platform testing less convenient than it need be.

I'll take a look at those functions next week.

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1600>
__________________________________


More information about the Python-bugs-list mailing list