This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_long fails
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: tim.peters Nosy List: mbrierst, tim.peters
Priority: normal Keywords:

Created on 2003-01-31 20:44 by mbrierst, last changed 2022-04-10 16:06 by admin. This issue is now closed.

Messages (2)
msg14368 - (view) Author: Michael Stone (mbrierst) Date: 2003-01-31 20:44
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.
msg14369 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2003-02-03 16:41
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.
History
Date User Action Args
2022-04-10 16:06:24adminsetgithub: 37887
2003-01-31 20:44:05mbrierstcreate