[Python-Dev] Re: Re: marshal / unmarshal

Fredrik Lundh fredrik at pythonware.com
Sat Apr 9 14:53:15 CEST 2005


Skip Montanaro wrote:

> Are float("inf") and float("nan") supported everywhere?

nope.

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

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

> As a starting point can it be agreed on whether they should be supported?

that would be nice.

> In either case, we should then know how to fix marshal.loads (and probably
> pickle.loads).

pickle doesn't have the INF=>1.0 bug:

>>> import pickle
>>> pickle.loads(pickle.dumps(1e10000))
...
ValueError: invalid literal for float(): 1.#INF

>>> import cPickle
>>> cPickle.loads(cPickle.dumps(1e10000))
...
ValueError: could not convert string to float

>>> import marshal
>>> marshal.loads(marshal.dumps(1e10000))
1.0

</F> 





More information about the Python-Dev mailing list