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.
|