Martin Panter added the comment: That particular revision isn’t sound so bad; I think the next revision, 78fb7f8cd349, which adds the make_streams_binary() function that replaces the variables is a worry though.
This is the kind of code I use when I want to write binary data to stdout: output = sys.stdout.detach() sys.stdout = None # Avoid error message during shutdown, due to output being closed or garbage-collected output.write(...) This raises two issues: 1. Is the practice of setting sys.stdout to None documented or recommended anywhere? If not, could it be, or is there another way to do this? 2. The error message I am avoiding looks more broken than it could be: $ python3 -c 'from sys import stdout; stdout.detach().close()' Exception ignored in: $ The trailing dollar ($) sign just indicates that there was no newline printed. ---------- nosy: +vadmium _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue21364> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com