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

quoted-strings: Fix explicit octal recognition #354

Merged
merged 1 commit into from
Jan 11, 2021

Conversation

adrienverge
Copy link
Owner

@adrienverge adrienverge commented Jan 5, 2021

PyYAML implements YAML spec version 1.1, not 1.2. Hence, values starting
with 0o are not considered as numbers: they are just strings, so they
need quotes when quoted-strings: {required: true}.

>>> import yaml
>>> yaml.resolver.Resolver().resolve(yaml.nodes.ScalarNode, '100', (True, False))
'tag:yaml.org,2002:int'
>>> yaml.resolver.Resolver().resolve(yaml.nodes.ScalarNode, '0100', (True, False))
'tag:yaml.org,2002:int'
>>> yaml.resolver.Resolver().resolve(yaml.nodes.ScalarNode, '0o100', (True, False))
'tag:yaml.org,2002:str'

Let's try to prevent that.

Fixes #351.

PyYAML implements YAML spec version 1.1, not 1.2. Hence, values starting
with `0o` are not considered as numbers: they are just strings, so they
need quotes when `quoted-strings: {required: true}`.

>>> import yaml
>>> yaml.resolver.Resolver().resolve(yaml.nodes.ScalarNode, '100', (True, False))
'tag:yaml.org,2002:int'
>>> yaml.resolver.Resolver().resolve(yaml.nodes.ScalarNode, '0100', (True, False))
'tag:yaml.org,2002:int'
>>> yaml.resolver.Resolver().resolve(yaml.nodes.ScalarNode, '0o100', (True, False))
'tag:yaml.org,2002:str'

Let's try to prevent that.

Fixes #351.
@coveralls
Copy link

coveralls commented Jan 5, 2021

Coverage Status

Coverage increased (+0.002%) to 97.922% when pulling 1fa0c4a on fix/quoted-strings-explicit-octal-values into ee4d163 on master.

@adrienverge adrienverge merged commit 1b378ed into master Jan 11, 2021
@adrienverge adrienverge deleted the fix/quoted-strings-explicit-octal-values branch January 11, 2021 15:38
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

Successfully merging this pull request may close these issues.

Bug: Confict between required quoted strings and explicit octal
2 participants