Skip to content

Commit a995a11

Browse files
[3.13] pythongh-131038: Use text=True in subprocesses in test_perf_profiler (pythonGH-137117) (python#137125)
1 parent 8f41211 commit a995a11

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
@@ -312,6 +312,7 @@ def run_perf(cwd, *args, use_jit=False, **env_vars):
312312
stdout=subprocess.PIPE,
313313
stderr=subprocess.PIPE,
314314
env=env,
315+
text=True,
315316
)
316317
if proc.returncode:
317318
print(proc.stderr, file=sys.stderr)
@@ -321,10 +322,10 @@ def run_perf(cwd, *args, use_jit=False, **env_vars):
321322
jit_output_file = cwd + "/jit_output.dump"
322323
command = ("perf", "inject", "-j", "-i", output_file, "-o", jit_output_file)
323324
proc = subprocess.run(
324-
command, stderr=subprocess.PIPE, stdout=subprocess.PIPE, env=env
325+
command, stderr=subprocess.PIPE, stdout=subprocess.PIPE, env=env, text=True
325326
)
326327
if proc.returncode:
327-
print(proc.stderr)
328+
print(proc.stderr, file=sys.stderr)
328329
raise ValueError(f"Perf failed with return code {proc.returncode}")
329330
# Copy the jit_output_file to the output_file
330331
os.rename(jit_output_file, output_file)
@@ -336,10 +337,9 @@ def run_perf(cwd, *args, use_jit=False, **env_vars):
336337
stderr=subprocess.PIPE,
337338
env=env,
338339
check=True,
340+
text=True,
339341
)
340-
return proc.stdout.decode("utf-8", "replace"), proc.stderr.decode(
341-
"utf-8", "replace"
342-
)
342+
return proc.stdout, proc.stderr
343343

344344

345345
class TestPerfProfilerMixin:

0 commit comments

Comments
 (0)