Skip to content

Commit

Permalink
Use utf-8 encoding at subprocess.run() (#3454)
Browse files Browse the repository at this point in the history
* Use utf-8 encoding at subprocess.run()

* Fix format

---------

Co-authored-by: HRUSHIKESH DOKALA <[email protected]>
  • Loading branch information
giorgossideris and Hk669 authored Aug 30, 2024
1 parent 084532e commit 4577524
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions autogen/coding/local_commandline_code_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,12 @@ def _setup_functions(self) -> None:
cmd = [py_executable, "-m", "pip", "install"] + required_packages
try:
result = subprocess.run(
cmd, cwd=self._work_dir, capture_output=True, text=True, timeout=float(self._timeout)
cmd,
cwd=self._work_dir,
capture_output=True,
text=True,
timeout=float(self._timeout),
encoding="utf-8",
)
except subprocess.TimeoutExpired as e:
raise ValueError("Pip install timed out") from e
Expand Down Expand Up @@ -303,7 +308,13 @@ def _execute_code_dont_check_setup(self, code_blocks: List[CodeBlock]) -> Comman

try:
result = subprocess.run(
cmd, cwd=self._work_dir, capture_output=True, text=True, timeout=float(self._timeout), env=env
cmd,
cwd=self._work_dir,
capture_output=True,
text=True,
timeout=float(self._timeout),
env=env,
encoding="utf-8",
)
except subprocess.TimeoutExpired:
logs_all += "\n" + TIMEOUT_MSG
Expand Down

0 comments on commit 4577524

Please sign in to comment.