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

Inline tables with inf/nan as values fail to parse #403

Open
benjyw opened this issue Aug 13, 2022 · 1 comment
Open

Inline tables with inf/nan as values fail to parse #403

benjyw opened this issue Aug 13, 2022 · 1 comment

Comments

@benjyw
Copy link

benjyw commented Aug 13, 2022

In a regular table:

>>> toml.loads("[x.y]\nz = nan")
{'x': {'y': {'z': nan}}}

As expected.

But in an inline table:

>>> toml.loads("[x.y]\nz = 'nan'")
Traceback (most recent call last):
  File "toml/decoder.py", line 511, in loads
    ret = decoder.load_line(line, currentlevel, multikey,
  File "toml/decoder.py", line 778, in load_line
    value, vtype = self.load_value(pair[1], strictly_valid)
  File "toml/decoder.py", line 883, in load_value
    self.load_inline_object(v, inline_object)
  File "toml/decoder.py", line 677, in load_inline_object
    raise ValueError("Invalid inline table value encountered")
ValueError: Invalid inline table value encountered

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "toml/decoder.py", line 514, in loads
    raise TomlDecodeError(str(err), original, pos)
toml.decoder.TomlDecodeError: Invalid inline table value encountered (line 2 column 1 char 4)

Whereas I would have expected the same result as in the regular table case.

@benjyw
Copy link
Author

benjyw commented Aug 13, 2022

Note that inf, nan, +inf and +nan fail, but -inf and -nan succeed.

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