[Python-Dev] Re: marshal / unmarshal

Fredrik Lundh fredrik at pythonware.com
Sun Apr 10 17:29:24 CEST 2005


Scott David Daniels wrote:

>  From yesterday's sprint

sprint?  I was beginning to wonder why nobody cared about this;
guess I missed the announcement ;-)

> At the least a change like this will catch the unpacking:
> in marshal.c (around line 500) in function r_object:

> PyFPE_START_PROTECT("atof", return 0)
> - dx = PyOS_ascii_atof(buf);
> + dx = PyOS_ascii_strtod(buf, &endptr);
> PyFPE_END_PROTECT(dx)

the PROTECT contents should probably match the function
you're using.

> + if buf + n != &endptr) {
> + PyErr_SetString(PyExc_ValueError,
> + "not all marshalled float text read");
> + return NULL;

this will fix the problem, sure.  I still think it would be cleaner
to reuse the float() semantics, since marshal.dumps uses repr().
to do that, you should use the code in floatobject.c (it wraps
strtod in additional logic designed to take care of various plat-
form quirks).

but nevermind, you have a patch and I don't.  if nobody objects,
go ahead and check it in.

</F>





More information about the Python-Dev mailing list