Skip to content

Commit fc911a9

Browse files
[3.14] gh-131038: Use text=True in subprocesses in test_perf_profiler (GH-137117) (#137124)
1 parent 5746e06 commit fc911a9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Lib/test/test_perf_profiler.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ def run_perf(cwd, *args, use_jit=False, **env_vars):
318318
stdout=subprocess.PIPE,
319319
stderr=subprocess.PIPE,
320320
env=env,
321+
text=True,
321322
)
322323
if proc.returncode:
323324
print(proc.stderr, file=sys.stderr)
@@ -327,10 +328,10 @@ def run_perf(cwd, *args, use_jit=False, **env_vars):
327328
jit_output_file = cwd + "/jit_output.dump"
328329
command = ("perf", "inject", "-j", "-i", output_file, "-o", jit_output_file)
329330
proc = subprocess.run(
330-
command, stderr=subprocess.PIPE, stdout=subprocess.PIPE, env=env
331+
command, stderr=subprocess.PIPE, stdout=subprocess.PIPE, env=env, text=True
331332
)
332333
if proc.returncode:
333-
print(proc.stderr)
334+
print(proc.stderr, file=sys.stderr)
334335
raise ValueError(f"Perf failed with return code {proc.returncode}")
335336
# Copy the jit_output_file to the output_file
336337
os.rename(jit_output_file, output_file)
@@ -342,10 +343,9 @@ def run_perf(cwd, *args, use_jit=False, **env_vars):
342343
stderr=subprocess.PIPE,
343344
env=env,
344345
check=True,
346+
text=True,
345347
)
346-
return proc.stdout.decode("utf-8", "replace"), proc.stderr.decode(
347-
"utf-8", "replace"
348-
)
348+
return proc.stdout, proc.stderr
349349

350350

351351
class TestPerfProfilerMixin:

0 commit comments

Comments
 (0)