Skip to content

Commit 460a267

Browse files
authored
Merge pull request #351 from thisisthepy/feat/typedpython-msvc-output-encoding
TypedPython: decode cl.exe output in the console code page
2 parents b6c1aed + b159f27 commit 460a267

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

  • python-multiplatform-ksp/src/main/python/typedpython

‎python-multiplatform-ksp/src/main/python/typedpython/cbuild.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def _find_vcvars() -> Path:
164164
f"with C++' workload ({MSVC_COMPONENT}), or run from a 'x64 Native Tools' prompt.")
165165
run = subprocess.run(
166166
[str(vswhere), "-latest", "-products", "*", "-requires", MSVC_COMPONENT,
167-
"-property", "installationPath"], capture_output=True, text=True)
167+
"-property", "installationPath"], capture_output=True, encoding="oem", errors="replace")
168168
root = run.stdout.strip().splitlines()[0].strip() if run.returncode == 0 and run.stdout.strip() else ""
169169
if not root:
170170
raise CBuildError(
@@ -229,7 +229,8 @@ def build(c_source: str, module_name: str, out_dir: Path, runtime_dir: Path | No
229229
env = msvc_env()
230230
cmd = msvc_command(_msvc_cl(env), c_file, so, include, runtime, flags,
231231
gil_disabled=free_threaded(ext_suffix))
232-
run = subprocess.run(cmd, capture_output=True, text=True, env=env)
232+
# cl.exe writes in the console code page (CP949 on Korean Windows), not UTF-8
233+
run = subprocess.run(cmd, capture_output=True, encoding="oem", errors="replace", env=env)
233234
if run.returncode != 0 or not so.is_file():
234235
# cl.exe reports its errors on stdout
235236
raise CBuildError(f"C compiler failed ({run.returncode}): {subprocess.list2cmdline(cmd)}\n"

0 commit comments

Comments
 (0)