Skip to content

Commit f569b3d

Browse files
committed
fix(qualify): decode Windows player smoke output safely
1 parent 4408bfd commit f569b3d

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

scripts/player-package.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,34 +1103,34 @@ def verify(arguments: argparse.Namespace) -> int:
11031103
env = portable_runtime_environment(root, arguments.platform)
11041104
if arguments.run_smoke:
11051105
smoke_executable = console_executable or executable
1106-
version = subprocess.run([str(smoke_executable), "--version"], cwd=root, env=env, text=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, check=False)
1106+
version = subprocess.run([str(smoke_executable), "--version"], cwd=root, env=env, text=True, encoding="utf-8", errors="replace", stdout=subprocess.PIPE, stderr=subprocess.STDOUT, check=False)
11071107
if version.returncode != 0:
11081108
raise SystemExit(f"package verification: packaged mpv --version failed\n{version.stdout}")
11091109
if not version.stdout.strip():
11101110
raise SystemExit("package verification: packaged mpv --version produced no console output")
11111111
if arguments.platform == "windows-x64":
11121112
wrapper = root / "bin/openjoc-mpv.cmd"
11131113
comspec = os.environ.get("COMSPEC", "cmd.exe")
1114-
wrapper_version = subprocess.run([comspec, "/d", "/c", str(wrapper), "--version"], cwd=root, env=env, text=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, check=False)
1114+
wrapper_version = subprocess.run([comspec, "/d", "/c", str(wrapper), "--version"], cwd=root, env=env, text=True, encoding="utf-8", errors="replace", stdout=subprocess.PIPE, stderr=subprocess.STDOUT, check=False)
11151115
if wrapper_version.returncode != 0 or not wrapper_version.stdout.strip():
11161116
raise SystemExit(f"package verification: openjoc-mpv.cmd --version failed\n{wrapper_version.stdout}")
11171117
help_command = [comspec, "/d", "/c", str(wrapper), "--ad=help"]
11181118
else:
11191119
help_command = [str(smoke_executable), f"--config-dir={root / 'config'}", "--ad=help"]
1120-
help_result = subprocess.run(help_command, cwd=root, env=env, text=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, check=False)
1120+
help_result = subprocess.run(help_command, cwd=root, env=env, text=True, encoding="utf-8", errors="replace", stdout=subprocess.PIPE, stderr=subprocess.STDOUT, check=False)
11211121
if help_result.returncode != 0 or "libopenjoc" not in help_result.stdout or "eac3" not in help_result.stdout:
11221122
raise SystemExit(f"package verification: decoder visibility failed\n{help_result.stdout}")
11231123
print(f"mpv console --version: {version.stdout.splitlines()[0]}")
11241124
print("mpv decoder inventory: eac3=PASS libopenjoc=PASS")
11251125
if arguments.platform == "windows-x64" and arguments.fixture:
11261126
fixture = arguments.fixture
11271127
fixture_argument = native_windows_path(fixture)
1128-
playback = subprocess.run([comspec, "/d", "/c", str(wrapper), fixture_argument, "--ao=null", "--vo=null"], cwd=root, env=env, text=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, check=False)
1128+
playback = subprocess.run([comspec, "/d", "/c", str(wrapper), fixture_argument, "--ao=null", "--vo=null"], cwd=root, env=env, text=True, encoding="utf-8", errors="replace", stdout=subprocess.PIPE, stderr=subprocess.STDOUT, check=False)
11291129
if playback.returncode != 0 or not playback.stdout.strip():
11301130
raise SystemExit(f"package verification: Windows console JOC playback failed for {fixture_argument}\n{playback.stdout}")
11311131
print("openjoc-mpv.cmd synthetic JOC console playback: PASS")
11321132
if os.name == "nt" and hasattr(signal, "CTRL_BREAK_EVENT"):
1133-
process = subprocess.Popen([comspec, "/d", "/c", str(wrapper), fixture_argument, "--ao=null", "--vo=null", "--loop=inf"], cwd=root, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP, text=True)
1133+
process = subprocess.Popen([comspec, "/d", "/c", str(wrapper), fixture_argument, "--ao=null", "--vo=null", "--loop=inf"], cwd=root, env=env, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP, text=True, encoding="utf-8", errors="replace")
11341134
try:
11351135
time.sleep(1)
11361136
process.send_signal(signal.CTRL_BREAK_EVENT)
@@ -1155,7 +1155,7 @@ def verify(arguments: argparse.Namespace) -> int:
11551155
missing.rename(missing.with_suffix(missing.suffix + ".missing"))
11561156
isolated_executable = isolated / executable.relative_to(root)
11571157
isolated_env = portable_runtime_environment(isolated, arguments.platform)
1158-
failure = subprocess.run([str(isolated_executable), "--version"], cwd=isolated, env=isolated_env, text=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, check=False)
1158+
failure = subprocess.run([str(isolated_executable), "--version"], cwd=isolated, env=isolated_env, text=True, encoding="utf-8", errors="replace", stdout=subprocess.PIPE, stderr=subprocess.STDOUT, check=False)
11591159
if arguments.platform == "windows-x64":
11601160
owners = [isolated_executable, *sorted((isolated / "bin").glob("*.dll"))]
11611161
imported = any(

0 commit comments

Comments
 (0)