David Wilson <d...@botanicus.net> added the comment:
A real example of where returning the partial buffer is dangerous would be EBADF. - Repeated reading succeeds, building up a partial buffer. Another thread runs, and buggy code causes an unrelated fd blonging to the file object to be closed. - Original thread resumes, calls read(), which now returns EBADF. If partial buffer is returned and EBADF is masked, and user only ever calls readall() once, a potentially deadly IO corruption bug is completely hidden in their code. I think the correct behaviour in the case of 'bad' errno must remain that the partial buffer is discarded, the interface does not seem to make room for any safe+better option So I think to reach the desired outcome of this ticket, the suggested approach is to add special handling for a small list of errnos generally accepted to unambiguously mean EOF, and in that special case, allow returning the 'partial' (actually complete) buffer. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue37696> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com