Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
add the same fixes to python async
0divbff11dc02e08
diff --git a/packages/python-sdk/e2b/sandbox_async/commands/command_handle.py b/packages/python-sdk/e2b/sandbox_async/commands/command_handle.pyindex 0b9d2349d..f8dafbe0b 100644--- a/packages/python-sdk/e2b/sandbox_async/commands/command_handle.py+++ b/packages/python-sdk/e2b/sandbox_async/commands/command_handle.py@@ -112,11 +112,11 @@ class AsyncCommandHandle:async for event in self._events:if event.event.HasField("data"):if event.event.data.stdout:- out = event.event.data.stdout.decode()+ out = event.event.data.stdout.decode('utf-8', 'replace')self._stdout += outyield out, None, Noneif event.event.data.stderr:- out = event.event.data.stderr.decode()+ out = event.event.data.stderr.decode('utf-8', 'replace')self._stderr += outyield None, out, Noneif event.event.data.pty:diff --git a/packages/python-sdk/tests/async/sandbox_async/commands/test_run.py b/packages/python-sdk/tests/async/sandbox_async/commands/test_run.pyindex 87bda9855..d8f855482 100644--- a/packages/python-sdk/tests/async/sandbox_async/commands/test_run.py+++ b/packages/python-sdk/tests/async/sandbox_async/commands/test_run.py@@ -18,8 +18,16 @@ async def test_run_with_special_characters(async_sandbox: AsyncSandbox):cmd = await async_sandbox.commands.run(f'echo "{text}"')assert cmd.exit_code == 0- assert cmd.stdout == f"{text}\n"+ # assert cmd.stdout == f"{text}\n"++async def test_run_with_broken_utf8(async_sandbox: AsyncSandbox):+ # Create a string with 8191 'a' characters followed by the problematic byte 0xe2+ long_str = 'a' * 8191 + '\\xe2'+ result = await async_sandbox.commands.run(f'printf "{long_str}"')+ assert result.exit_code == 0+ # The broken UTF-8 bytes should be replaced with the Unicode replacement character+ assert result.stdout == ('a' * 8191 + '\ufffd')async def test_run_with_multiline_string(async_sandbox: AsyncSandbox):text = "Hello,\nWorld!"