[New-bugs-announce] [issue7335] int/long discrepancy when formatting zero with ".0d"

Mark Dickinson report at bugs.python.org
Mon Nov 16 19:28:41 CET 2009

New submission from Mark Dickinson <dickinsm at gmail.com>:

In Python 2.x we have:

>>> "%.0d" % 0
>>> "%.0d" % 0L

In Python 3.x:

>>> "%.0d" % 0

I think the 2.x behaviour for int comes directly from C's sprintf 
behaviour:  section, p8 of the C99 standard says:

"The result of converting a zero value with a precision of zero is no 

I'm not sure which the more sensible behaviour is, but in 2.x, int and 
long should behave in the same way.  Fixing long to behave like int 
seems both simplest and least likely to break existing code.

components: Interpreter Core
messages: 95356
nosy: eric.smith, mark.dickinson
priority: normal
severity: normal
status: open
title: int/long discrepancy when formatting zero with ".0d"
type: behavior
versions: Python 2.6, Python 2.7

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list