[Python-bugs-list] [ python-Bugs-678375 ] test_long fails

SourceForge.net noreply@sourceforge.net
Mon, 03 Feb 2003 08:41:09 -0800


Bugs item #678375, was opened at 2003-01-31 15:44
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=678375&group_id=5470

Category: Python Library
Group: Python 2.3
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Michael Stone (mbrierst)
>Assigned to: Tim Peters (tim_one)
Summary: test_long fails

Initial Comment:

on linux kernel 2.2.17, libc2.2

this code demonstrates the problem:

s='12345'*1000
float(s)

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ValueError: invalid literal for float(): 1234512...

caused by PyFloat_FromString in floatobject.c:
Testing shows strtod only reads the first 721 digits of the string it gets (after any leading zeros).  Python then thinks the remaining digits aren't valid because strtod did not process them, even though strtod returned inf as is proper.  I guess this is a strtod problem, maybe it depends on the version of libc?

PyFloat_FromString could deal with this case, but really only correctly if it reimpliments strtod, as there could be an exponent way on the end of the string.  I don't know what the correct solution to this is, but surely something should at least be done about the failed test.

----------------------------------------------------------------------

>Comment By: Tim Peters (tim_one)
Date: 2003-02-03 11:41

Message:
Logged In: YES 
user_id=31435

IMO the platform strtod() doesn't conform to the C standard 
here, and is certainly unreasonable in this case.  You should 
file a bug report against it.  (Wheher or not it returns Inf isn't 
the point here, it's how it sets strtod's **endptr argument -- 
the standard has clear rules about that).

We're not going to write our own strtod(), so Guido changed 
the test to use a 600-character string instead.  That should 
hide the symptom for you.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=678375&group_id=5470