[docs] [issue12743] C API marshalling doc contains XXX

Ronald Oussoren report at bugs.python.org
Fri Jun 14 13:08:34 CEST 2013


Ronald Oussoren added the comment:

>From reading the source of Python/marshal.c it seems that the read function's raise an exception on I/O errors, but don't return a specific value (that is, sentence starting with "It appears that" is wrong). 

PyMarshal_ReadLongFromFile calls r_long, this calls r_string without checking for errors and calculates the return value from the buffer passed to r_string. On I/O errors the buffer may not have been filled at all and contains random data (whatever happened to be on the stack).

Likewise for PyMarhal_ReadShortFromFile (through r_short instead of r_long).

r_string does raise an exception on I/O errors or short reads, but reading from FILE* and Python objects.

The most straightforward documentation update would be:

* Remove the entire XXX paragraph

* Add text to the documentation for PyMarshal_ReadLongFromFile and PyMarshal_ReadShortFromFile:  On error sets the appopriate exception (:exc:`EOFError`), but does not return a specific value. Use :func:`PyErr_Occurred` to check for errors.

----------
nosy: +ronaldoussoren

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12743>
_______________________________________


More information about the docs mailing list