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

CSafeDumper doesn't appear to respect allow_unicode=True #771

Open
indrat opened this issue Dec 4, 2023 · 0 comments
Open

CSafeDumper doesn't appear to respect allow_unicode=True #771

indrat opened this issue Dec 4, 2023 · 0 comments

Comments

@indrat
Copy link

indrat commented Dec 4, 2023

The behaviour of CSafeDumper differs from SafeDumper with respect to the allow_unicode parameter. SafeDumper will emit the unicode unescaped whereas CSafeDumper appears to ignore the parameter and emits the \U.... escaped version of the unicode character.

Is this expected?

Example:

Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux
PyYAML     6.0.1
>>> import yaml
>>> text = "😸 is not escaped"
>>> print(yaml.dump_all([text], encoding="utf-8", allow_unicode=True, Dumper=yaml.SafeDumper).decode("utf-8"))
😸 is not escaped

>>> print(yaml.dump_all([text], encoding="utf-8", allow_unicode=True, Dumper=yaml.CSafeDumper).decode("utf-8"))
"\U0001F638 is not escaped"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant