STINNER Victor added the comment:

For Python 2, file.read() looks wrong: if only checks ferror() if fread() 
returns 0, whereas Py_UniversalNewlineFread() can call fread() more than once, 
and according to fread() manual page, fread() result can be different than 0 on 
error.

"If an error occurs, or the end of the file is reached, the return value is a 
short item count (or zero)."
http://linux.die.net/man/3/fread

Attached fileobject.c rewrites error handling in fileobject.c. The main change 
if that ferror() is called even if fread() does not return 0.

----------
Added file: http://bugs.python.org/file35833/fileobject.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue21090>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to