Author alexandre.vassalotti
Recipients alexandre.vassalotti
Date 2007-12-11.22:02:25
SpamBayes Score 0.0377911
Marked as misclassified No
Message-id <1197410546.31.0.23440598734.issue1596@psf.upfronthosting.co.za>
In-reply-to
Content
I think Python 2.x should mimic, or improve on, the behavior of Py3k for
handling broken pipes. That is:
  1. Don't print the message "close failed: [Errno 32] Broken pipe",
from filemodule.c; since this is impossible to override from Python.
  2. Check sys.stdout if it's closed before calling the print routine.
Raise an IOError if so.

Finally, here's some examples to illustrate what I am saying:

alex:~% python -c "print" | head -n0
close failed: [Errno 32] Broken pipe

alex:~% python -c "while 1: print" | head -n0
[The loop continues running, even if the output stream is closed]
^C
Traceback (most recent call last):
  File "<string>", line 1, in <module>
KeyboardInterrupt
close failed: [Errno 32] Broken pipe

alex:~% py3k -c "print()" | head -n0
alex:~% py3k -c "while 1: print()" | head -n0
Traceback (most recent call last):
 ...
IOError: [Errno 32] Broken pipe
History
Date User Action Args
2007-12-11 22:02:26alexandre.vassalottisetspambayes_score: 0.0377911 -> 0.0377911
recipients: + alexandre.vassalotti
2007-12-11 22:02:26alexandre.vassalottisetspambayes_score: 0.0377911 -> 0.0377911
messageid: <1197410546.31.0.23440598734.issue1596@psf.upfronthosting.co.za>
2007-12-11 22:02:26alexandre.vassalottilinkissue1596 messages
2007-12-11 22:02:25alexandre.vassalotticreate