From 3c82dc64e0d60dcba6c61e792d8ed060ff9f139d Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Thu, 23 Sep 2021 22:37:55 -0700 Subject: [PATCH] Don't write to streams when pythonw makes them None. --- voussoirkit/pipeable.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/voussoirkit/pipeable.py b/voussoirkit/pipeable.py index 7454d72..46bda27 100644 --- a/voussoirkit/pipeable.py +++ b/voussoirkit/pipeable.py @@ -182,11 +182,14 @@ def _output(stream, line, end): stream.flush() def stdout(line='', end='\n'): - _output(sys.stdout, line, end) + # In pythonw, stdout is None. + if sys.stdout is not None: + _output(sys.stdout, line, end) def stderr(line='', end='\n'): - _output(sys.stderr, line, end) - + # In pythonw, stderr is None. + if sys.stderr is not None: + _output(sys.stderr, line, end) def go(args=None, *input_args, **input_kwargs): '''