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

Possible integer parsing issue #120

Open
mschubert opened this issue Sep 27, 2022 · 1 comment
Open

Possible integer parsing issue #120

mschubert opened this issue Sep 27, 2022 · 1 comment
Labels

Comments

@mschubert
Copy link

mschubert commented Sep 27, 2022

I just ran into a potential issue with integer parsing, when combing reading and writing of the yaml R package with other packages/languages.

According to the yaml integer specification:

Any “_” characters in the number are ignored, allowing a readable representation of large values

However, if I yaml::write_yaml(list("1_2_3"=4), file="test.yaml") this gives me the following resulting file:

1_2_3: 4.0

If I read this with with another parser (e.g., in Python) I will get a {123: 4}, where the 123 key is an integer.

To be safe, should the package maybe quote all "integer and underscores" keys/values?

@spgarbet spgarbet added the bug label Sep 28, 2022
@spgarbet
Copy link
Member

This is odd. The parser is a 1.1 parser which this was an extension that should be supported. I am treating this as a bug. Reference specification: https://yaml.org/type/int.html

Note: If the 1.2 conversion is ever completed, underscores in integers is no longer in specification. I would recommend against using this feature of 1.1. Some YAML 1.2 parsers are supporting it, although this is outside of the current specification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants