From 5ee2496d4222a818da2cc5b09a4aee3c1d11bfcd Mon Sep 17 00:00:00 2001 From: polishchuks Date: Sat, 15 Feb 2025 14:35:12 +0200 Subject: [PATCH] Enhance error handling and platform-specific command execution in Python executor --- hstest/testing/execution/process/python_executor.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hstest/testing/execution/process/python_executor.py b/hstest/testing/execution/process/python_executor.py index b121b145..8962482f 100644 --- a/hstest/testing/execution/process/python_executor.py +++ b/hstest/testing/execution/process/python_executor.py @@ -1,5 +1,7 @@ from __future__ import annotations +import os +import sys from hstest.testing.execution.process_executor import ProcessExecutor from hstest.testing.execution.searcher.python_searcher import PythonSearcher @@ -9,4 +11,9 @@ def __init__(self, source_name: str | None = None) -> None: super().__init__(PythonSearcher().find(source_name)) def _execution_command(self, *args: str): - return ["python", "-u", self.runnable.file, *list(args)] + cmd = ["python"] + if sys.platform == 'win32': + # Set UTF-8 encoding for stdin/stdout on Windows + cmd.extend(["-X", "utf8"]) + cmd.extend(["-u", self.runnable.file, *list(args)]) + return cmd