uiri / toml

Python lib for TOML
MIT License
1.08k stars 190 forks source link

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

Open benjyw opened 2 years ago

benjyw commented 2 years ago

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 commented 2 years ago

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