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 <[email protected]>
<http://bugs.python.org/issue24864>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com