Martin Panter added the comment:

Josiah’s code now seems to handle the four special cases like this:

* Reading a closed pipe raises BrokenPipeError. This is novel to me, and bends 
the current definition of the exception. But it appears to be the way Windows 
works at a lower level, and does make a bit of sense to me. However it is 
inconsistent with how normal reading from files, pipes and sockets works, which 
return the special value b"" in the equivalent case. Also various 
communications protocols use an empty packet to signal EOF.

* Reading an empty pipe returns b"". This is consistent with partial reads, 
which I like. However it could be surprising for someone used to b"" signalling 
EOF. Alternatives are returning None like RawIOBase.read(), and raising 
BlockingIOError like os.write() and socket.send().

* Writing to a closed pipe raises BrokenPipeError. This is consistent with how 
other APIs work, but since it is an asynchronous condition, a naive program may 
work sometimes without handling it, and then see suprious tracebacks or worse 
in other situations. Maybe dropping the data and setting a flag could be an 
alternative.

* Writing to a full pipe returns zero. This is consistent with partial writes, 
which I like. Alternatives are returning None like RawIOBase.write(), and 
raising BlockingIOError like os.write(), socket.send(), BufferedIOBase.write().

----------

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

Reply via email to