Skip to content

Commit

Permalink
chore: popen using utf8 encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
fatelei committed Nov 11, 2023
1 parent bf939ef commit b54fc7e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions interpreter/code_interpreters/subprocess_code_interpreter.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import queue
import subprocess
import threading
Expand Down Expand Up @@ -40,6 +41,8 @@ def start_process(self):
if self.process:
self.terminate()

my_env = os.environ.copy()
my_env['PYTHONIOENCODING'] = 'utf-8'
self.process = subprocess.Popen(
self.start_cmd.split(),
stdin=subprocess.PIPE,
Expand All @@ -48,6 +51,7 @@ def start_process(self):
text=True,
bufsize=0,
universal_newlines=True,
env=my_env
)
threading.Thread(
target=self.handle_stream_output,
Expand Down

0 comments on commit b54fc7e

Please sign in to comment.