Skip to content

Commit b5005e4

Browse files
committed
fix: correct JSON serialization in exec_code method
1 parent 817d5bc commit b5005e4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

apps/common/utils/tool_code.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def _createdir(self):
4040
def exec_code(self, code_str, keywords):
4141
self.validate_banned_keywords(code_str)
4242
_id = str(uuid.uuid7())
43-
success = '{"code":200,"msg":"成功","data":json.dumps(exec_result, default=str)}'
43+
success = '{"code":200,"msg":"成功","data":exec_result}'
4444
err = '{"code":500,"msg":str(e),"data":None}'
4545
result_path = f'{self.sandbox_path}/result/{_id}.result'
4646
python_paths = CONFIG.get_sandbox_python_package_paths().split(',')
@@ -65,7 +65,7 @@ def exec_code(self, code_str, keywords):
6565
globals_v[local] = locals_v[local]
6666
exec_result=f(**keywords)
6767
with open({result_path!a}, 'w') as file:
68-
file.write(json.dumps({success}))
68+
file.write(json.dumps({success}, default=str))
6969
except Exception as e:
7070
with open({result_path!a}, 'w') as file:
7171
file.write(json.dumps({err}))

0 commit comments

Comments
 (0)