Merge pull request #996 from thibautbus/fix/modkit-dump-dataset-utf8-decode

Fix: tools/modkit.py crashes on Windows when dumped text isn't representable in the system codepage
This commit is contained in:
bryanthaboi
2026-08-10 14:09:19 -04:00
committed by GitHub
+3 -3
View File
@@ -716,7 +716,7 @@ def run_loader(repo, mod_dir, findings, base="fixture", notes=None):
driver_path = handle.name driver_path = handle.name
try: try:
proc = subprocess.run([LUAJIT, driver_path], cwd=repo, proc = subprocess.run([LUAJIT, driver_path], cwd=repo,
capture_output=True, text=True, timeout=120) capture_output=True, text=True, encoding="utf-8", timeout=120)
except FileNotFoundError: except FileNotFoundError:
findings.append(Finding("MK100", "error", findings.append(Finding("MK100", "error",
f"cannot run {LUAJIT} (install luajit or " f"cannot run {LUAJIT} (install luajit or "
@@ -1056,7 +1056,7 @@ def check_data_dump(repo, path, base, rel):
driver = DUMP_DRIVER % (lua_quote(path), lua_quote(vanilla)) driver = DUMP_DRIVER % (lua_quote(path), lua_quote(vanilla))
try: try:
proc = subprocess.run([LUAJIT, "-e", driver], cwd=repo, proc = subprocess.run([LUAJIT, "-e", driver], cwd=repo,
capture_output=True, text=True, timeout=60) capture_output=True, text=True, encoding="utf-8", timeout=60)
except FileNotFoundError: except FileNotFoundError:
# the gate must fail closed: a missing interpreter is a broken # the gate must fail closed: a missing interpreter is a broken
# environment, not a clean mod # environment, not a clean mod
@@ -1416,7 +1416,7 @@ def dump_dataset(repo, base):
handle.close() handle.close()
try: try:
proc = subprocess.run([os.environ.get("LUA", "luajit"), handle.name], proc = subprocess.run([os.environ.get("LUA", "luajit"), handle.name],
cwd=repo, capture_output=True, text=True) cwd=repo, capture_output=True, text=True, encoding="utf-8")
finally: finally:
os.unlink(handle.name) os.unlink(handle.name)
if proc.returncode != 0: if proc.returncode != 0: