On 06.03.15 14:53, Victor Stinner wrote:
I propose to ignore BrokenPipeError in Popen.__exit__, as done in communicate(), for convinience: http://bugs.python.org/issue23570
Serhiy wants to keep BrokenPipeError, he wrote that file.close() should not ignore write errors (read the issue for details).
I rather said about file.__exit__.
I consider that BrokenPipeError on a pipe is different than a write error on a regular file.
EPIPE and SIGPIPE are designed to notify that the pipe is closed and that it's now inefficient to continue to write into this pipe.
And into the file like open('/dev/stdout', 'wb').
Ignoring BrokenPipeError in Popen.__exit__() respects this constrain because the method closes stdin and only returns when the process exited. So the caller will not write anything into stdin anymore.
And the caller will not write anything into the file after calling file.__exit__. I don't see large difference between open('file', 'wb') and Popen('cat
file', stdin=PIPE), between sys.stdout with redirecting stdout and running external program with Pipe().