[issue24864] errors writing to stdout are uncatchable and exit with status 0
Robert Collins
report at bugs.python.org
Fri Aug 14 12:38:08 CEST 2015
Robert Collins added the comment:
Oh, one nuance - the reason my except isn't triggering is that the write is happening in interpreter shutdown - in flush_std_files.
Adding a a flush there allows that to work, but its fugly:
---
import sys
try:
print("What... is your quest?")
# Workaround bug 24864: force the write to be immediate
sys.stdout.flush()
except:
sys.stderr.write("Exception in program.\n")
e = sys.exc_info()[1]
try:
# Workaround bug 24864 close the file so flush_std_files doesn't run
# during interpreter cleanup.
sys.stdout.close()
finally:
raise e from None
---
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24864>
_______________________________________
More information about the Python-bugs-list
mailing list