[Python-bugs-list] [ python-Bugs-659709 ] bogus computation of float length
noreply@sourceforge.net
noreply@sourceforge.net
Sun, 29 Dec 2002 11:44:58 -0800
Bugs item #659709, was opened at 2002-12-29 17:19
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=659709&group_id=5470
Category: None
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Martin v. Löwis (loewis)
Assigned to: M.-A. Lemburg (lemburg)
Summary: bogus computation of float length
Initial Comment:
The computation introduced in rev 2.70 of
stringobject.c:formatfloat is bogus. If the expression
"%.86f" %
999999999999999963589629496524800.00001
is computed, then the test whether this is smaller than
1e50 will succeed, so it continues to be printed as a
float. However, the result has 33 digits before the
decimal point, and 86 digits after the decimal point, so
the entire result will need 121 bytes, more than the 120
bytes of buffer available.
See Debian bug 172531 for how this crashes Python
2.1; for Python 2.2, it won't crash as the snprintf
protects the buffer. However, the result is still incorrect:
since the buffer is to small to represent 86 digits after
the decimal point, an exception should be raised.
----------------------------------------------------------------------
>Comment By: M.-A. Lemburg (lemburg)
Date: 2002-12-29 20:44
Message:
Logged In: YES
user_id=38388
Fix checked in.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=659709&group_id=5470