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

Strange issue with invalid YAML #801

Closed
inoa-jboliveira opened this issue May 20, 2024 · 4 comments
Closed

Strange issue with invalid YAML #801

inoa-jboliveira opened this issue May 20, 2024 · 4 comments

Comments

@inoa-jboliveira
Copy link

inoa-jboliveira commented May 20, 2024

PyYAML 6.0.1

>>> yaml.load('{1:2}', yaml.Loader)
{62: None}
>>> yaml.load('{1: 2}', yaml.Loader)
{1: 2}

The 1st case should throw a parsing error and I don't even know how 62 got in there. Is this an issue with the parser or maybe a difference from rev 1.1 and 1.2 of the standard, which pyyaml does not support?

@perlpunk
Copy link
Member

perlpunk commented May 20, 2024

Why should the first be a parsing error?
It's a mapping with one key 1:2, which is a sexagesimal number (base 60), e.g. 1 * 60 + 2 * 1. That's part of yAML 1.1, which PyYAML implements.
The value for the key is empty.
In block style it would be:

---
1:2:

For more info about the differences between YAML 1.1 and 1.2 check https://perlpunk.github.io/yaml-test-schema/schemas.html

If you don't want sexagesimal numbers and you want to process YAML 1.2 files, check out https://pypi.org/project/yamlcore/ which can be used on top of PyYAML.

@inoa-jboliveira
Copy link
Author

inoa-jboliveira commented May 20, 2024

Thank you for the explanation and the resources. Closing this issue

BTW, I've found this resource https://pyyaml.org/wiki/YAMLColonInFlowContext that makes no mention to base 60 numbers
when testing an yaml parser online which does seem based in pyyaml, but I have no idea who maintains this:
https://yaml-online-parser.appspot.com/

@inoa-jboliveira inoa-jboliveira closed this as not planned Won't fix, can't repro, duplicate, stale May 20, 2024
@perlpunk
Copy link
Member

I just had a quick look - https://yaml-online-parser.appspot.com/ is apparently using a very old copy of pyyaml (version 3.10):
https://github.com/ptarjan/online-yaml-parser/tree/master/yaml
Your example is something that was fixed in #45

@perlpunk
Copy link
Member

I opened an issue regarding the pyyaml version: ptarjan/online-yaml-parser#13

This issue was closed.
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

2 participants