Skip to content

Commit 624d14d

Browse files
committed
Safe server printing
1 parent acafd08 commit 624d14d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

interpreter/core/async_core.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def __init__(self, *args, **kwargs):
4747
self.output_queue = None
4848
self.unsent_messages = deque()
4949
self.id = os.getenv("INTERPRETER_ID", datetime.now().timestamp())
50-
self.print = True # Will print output
50+
self.print = False # Will print output
5151

5252
self.require_acknowledge = (
5353
os.getenv("INTERPRETER_REQUIRE_ACKNOWLEDGE", "False").lower() == "true"
@@ -133,7 +133,11 @@ def respond(self, run_code=None):
133133
if "format" in chunk and "base64" in chunk["format"]:
134134
print("\n[An image was produced]")
135135
else:
136-
print(chunk.get("content", ""), end="", flush=True)
136+
content = chunk.get("content", "")
137+
content = (
138+
str(content).encode("ascii", "ignore").decode("ascii")
139+
)
140+
print(content, end="", flush=True)
137141

138142
self.output_queue.sync_q.put(chunk)
139143

0 commit comments

Comments
 (0)