[Python-Dev] Re: marshal / unmarshal
Fredrik Lundh
fredrik at pythonware.com
Sat Apr 9 01:32:21 CEST 2005
Scott David Daniels wrote:
> What should marshal / unmarshal do with floating point NaNs (the case we
> are worrying about is Infinity) ? The current behavior is not perfect.
>
> Michael Spencer chased down a supposed "Idle" problem to (on Win2k):
> marshal.dumps(1e10000) == 'f\x061.#INF'
> marshal.loads('f\x061.#INF') == 1.0
>
> Should loads raise an exception?
> Somehow, I thing 1.0 is not the best possible representation for +Inf.
looks like marshal uses atof to parse the string, without bothering to
check for trailing junk... it should probably use a strtod instead, and
raise an exception if there's enough junk left at the end (see PyFloat_
FromString for sample code).
fwiw, here's what I get on a linux box:
>>> import marshal
>>> marshal.dumps(1e10000)
'f\x03inf'
>>> marshal.loads(_)
inf
and yes, someone should fix the NaN mess, but I guess everyone's too
busy removing unworthy developers from sourceforge to bother working
on stuff that's actually useful for real Python users...
</F>
More information about the Python-Dev
mailing list