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

"Y" does not round-trip in practice #791

Open
sjshuck opened this issue Mar 26, 2024 · 1 comment
Open

"Y" does not round-trip in practice #791

sjshuck opened this issue Mar 26, 2024 · 1 comment

Comments

@sjshuck
Copy link

sjshuck commented Mar 26, 2024

$ python -c 'import yaml; print(yaml.safe_dump(yaml.safe_load(""" foo: "Y" """)))'
foo: Y

Technically this isn't any more specific than a scalar, so it round-trips just fine per the spec. However, I know there's difference between YAML 1.1 and 1.2. Anyway, most parsers, in particular that used by Kubernetes, interprets Y as a boolean, which caused problems for me. The output should have quotes around the Y to keep it a string.

Tested with pyyaml 6.0.1.

@sjshuck
Copy link
Author

sjshuck commented Mar 26, 2024

Also note that pyyaml.org/wiki/PyYAMLDocumentation links to the YAML 1.1 spec for the syntax, but is otherwise not explicit about the spec version. The only version that the above behavior conforms to is YAML 1.2.2+, in which true and false are the only boolean values.

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