is closed under a program like ``head``; however this only
works on Python 2. On Python 3, there is not yet a known way to
suppress the BrokenPipeError warnings without prematurely terminating
the program via signals. fixes #160.
Added comments to http://bugs.python.org/issue11380 to see what the
status is on py3k.
if not isinstance(t, binary_type):
t = t.encode(encoding, 'replace')
t = t.decode(encoding)
- stream.write(t)
+ try:
+ stream.write(t)
+ except IOError:
+ # suppress "broken pipe" errors.
+ # no known way to handle this on Python 3 however
+ # as the exception is "ignored" (noisily) in TextIOWrapper.
+ break
def coerce_resource_to_filename(fname):
"""Interpret a filename as either a filesystem location or as a package resource.
.. changelog::
:version: 0.6.4
+ .. change::
+ :tags: bug
+ :tickets: 160
+
+ Suppressed IOErrors which can raise when program output pipe
+ is closed under a program like ``head``; however this only
+ works on Python 2. On Python 3, there is not yet a known way to
+ suppress the BrokenPipeError warnings without prematurely terminating
+ the program via signals.
+
.. change::
:tags: bug
:tickets: 179