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@bugs.python.org> <http://bugs.python.org/issue12743> _______________________________________