From 7c178919e8a8ef9104bf415c5529c63db707abb6 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 25 Oct 2015 19:51:41 -0400 Subject: Account for no encoding at all... --- tests/helpers.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/helpers.py b/tests/helpers.py index 67d51b2..fa94b10 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -17,9 +17,11 @@ def run_command(cmd): # In some strange cases (PyPy3 in a virtualenv!?) the stdout encoding of # the subprocess is set incorrectly to ascii. Use an environment variable # to force the encoding to be the same as ours. - sub_env = dict(os.environ, PYTHONIOENCODING=sys.__stdout__.encoding) - print("__stdout__: %r, enc = %r" % (sys.__stdout__, sys.__stdout__.encoding)) - print("stdout: %r, enc = %r" % (sys.stdout, sys.stdout.encoding)) + sub_env = dict(os.environ) + encoding = sys.__stdout__.encoding + if encoding: + sub_env['PYTHONIOENCODING'] = encoding + proc = subprocess.Popen( cmd, shell=True, -- cgit v1.2.1