Skip to content

Commit 3ce04a1

Browse files
authored
Merge pull request #3432 from pypa/feature/subprocess-text
Use text mode for subprocess, avoiding unicode sandwich.
2 parents 5619b39 + a56be0e commit 3ce04a1

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

setuptools/tests/test_windows_wrappers.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ def test_basic(self, tmpdir):
107107
'arg5 a\\\\b',
108108
]
109109
proc = subprocess.Popen(
110-
cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE)
111-
stdout, stderr = proc.communicate('hello\nworld\n'.encode('ascii'))
112-
actual = stdout.decode('ascii').replace('\r\n', '\n')
110+
cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE, text=True)
111+
stdout, stderr = proc.communicate('hello\nworld\n')
112+
actual = stdout.replace('\r\n', '\n')
113113
expected = textwrap.dedent(r"""
114114
\foo-script.py
115115
['arg1', 'arg 2', 'arg "2\\"', 'arg 4\\', 'arg5 a\\\\b']
@@ -148,9 +148,11 @@ def test_with_options(self, tmpdir):
148148
cmd,
149149
stdout=subprocess.PIPE,
150150
stdin=subprocess.PIPE,
151-
stderr=subprocess.STDOUT)
151+
stderr=subprocess.STDOUT,
152+
text=True,
153+
)
152154
stdout, stderr = proc.communicate()
153-
actual = stdout.decode('ascii').replace('\r\n', '\n')
155+
actual = stdout.replace('\r\n', '\n')
154156
expected = textwrap.dedent(r"""
155157
\foo-script.py
156158
[]
@@ -188,7 +190,7 @@ def test_basic(self, tmpdir):
188190
]
189191
proc = subprocess.Popen(
190192
cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE,
191-
stderr=subprocess.STDOUT)
193+
stderr=subprocess.STDOUT, text=True)
192194
stdout, stderr = proc.communicate()
193195
assert not stdout
194196
assert not stderr

0 commit comments

Comments
 (0)