From a56be0e5f6aa6ca4df92a5b09cc172f7c3120e30 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 4 Jul 2022 10:23:37 -0400 Subject: [PATCH] Use text mode for subprocess, avoiding unicode sandwich. --- setuptools/tests/test_windows_wrappers.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/setuptools/tests/test_windows_wrappers.py b/setuptools/tests/test_windows_wrappers.py index 8ac9bd072c..f8b82fcc37 100644 --- a/setuptools/tests/test_windows_wrappers.py +++ b/setuptools/tests/test_windows_wrappers.py @@ -107,9 +107,9 @@ def test_basic(self, tmpdir): 'arg5 a\\\\b', ] proc = subprocess.Popen( - cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE) - stdout, stderr = proc.communicate('hello\nworld\n'.encode('ascii')) - actual = stdout.decode('ascii').replace('\r\n', '\n') + cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE, text=True) + stdout, stderr = proc.communicate('hello\nworld\n') + actual = stdout.replace('\r\n', '\n') expected = textwrap.dedent(r""" \foo-script.py ['arg1', 'arg 2', 'arg "2\\"', 'arg 4\\', 'arg5 a\\\\b'] @@ -148,9 +148,11 @@ def test_with_options(self, tmpdir): cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE, - stderr=subprocess.STDOUT) + stderr=subprocess.STDOUT, + text=True, + ) stdout, stderr = proc.communicate() - actual = stdout.decode('ascii').replace('\r\n', '\n') + actual = stdout.replace('\r\n', '\n') expected = textwrap.dedent(r""" \foo-script.py [] @@ -188,7 +190,7 @@ def test_basic(self, tmpdir): ] proc = subprocess.Popen( cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE, - stderr=subprocess.STDOUT) + stderr=subprocess.STDOUT, text=True) stdout, stderr = proc.communicate() assert not stdout assert not stderr