Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow serialize_to_str to work with non ascii when dumping via json.d… #2714

Merged
merged 3 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion autogen/function_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,4 +353,4 @@ def serialize_to_str(x: Any) -> str:
elif isinstance(x, BaseModel):
return model_dump_json(x)
else:
return json.dumps(x)
return json.dumps(x, ensure_ascii=False)
4 changes: 4 additions & 0 deletions test/test_function_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@ async def f(
assert actual[1] == "EUR"


def test_serialize_to_str_with_nonascii() -> None:
assert serialize_to_str("中文") == "中文"

Hk669 marked this conversation as resolved.
Show resolved Hide resolved

def test_serialize_to_json() -> None:
assert serialize_to_str("abc") == "abc"
assert serialize_to_str(123) == "123"
Expand Down
Loading