From 9f14028a4ebde0d6198855539f40e500a48b0c15 Mon Sep 17 00:00:00 2001 From: Tyler Fox Date: Wed, 1 Nov 2023 22:06:09 -0700 Subject: [PATCH] Add a comment explaining what's going on --- preditor/stream/director.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/preditor/stream/director.py b/preditor/stream/director.py index 87206703..5837d079 100644 --- a/preditor/stream/director.py +++ b/preditor/stream/director.py @@ -32,6 +32,9 @@ def __init__(self, manager, state, old_stream=None, *args, **kwargs): old_stream = None elif old_stream is None: if state == STDOUT: + # On Windows if we're in pythonw.exe, then sys.stdout is named "nul" + # And it uses cp1252 encoding (which breaks with unicode) + # So if we find this nul TextIOWrapper, it's safe to just skip it if getattr(sys.stdout, 'name', '') != 'nul': old_stream = sys.stdout elif state == STDERR: