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

Fix loading values when a line has " }" after a boolean #224

Merged
merged 2 commits into from
Jan 4, 2019

Conversation

thombashi
Copy link
Contributor

@thombashi thombashi commented Dec 31, 2018

This PR aims to fix psf/black#637

The issue can be reproduce as follows (Python 3.7 with toml 0.10.0):

>>> import toml
>>> toml.loads(r"""
... [tool.poetry.dev-dependencies]
... black = { python=">3.6", version=">=18.9b0", allow_prereleases=true }
... """)
Traceback (most recent call last):
  File "/home/.../site-packages/toml/decoder.py", line 456, in loads
    multibackslash)
  File "/home/.../site-packages/toml/decoder.py", line 725, in load_line
    value, vtype = self.load_value(pair[1], strictly_valid)
  File "/home/.../site-packages/toml/decoder.py", line 805, in load_value
    self.load_inline_object(v, inline_object)
  File "/home/.../site-packages/toml/decoder.py", line 624, in load_inline_object
    multibackslash)
  File "/home/.../site-packages/toml/decoder.py", line 678, in load_line
    raise ValueError("Invalid date or number")
ValueError: Invalid date or number

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 4, in <module>
  File "/home/.../site-packages/toml/decoder.py", line 458, in loads
    raise TomlDecodeError(str(err), original, pos)
toml.decoder.TomlDecodeError: Invalid date or number (line 3 column 1 char 32)

@uiri
Copy link
Owner

uiri commented Jan 3, 2019

Hi Tsuyoshi,

Thank you for the pull request!

I think the test case should be added to the toml test suite rather than here. test_api.py is supposed to test the python library API, not valid/invalid TOML test cases.

The bug fix itself looks good.

@thombashi
Copy link
Contributor Author

thombashi commented Jan 3, 2019

Hi,

Thank you for reviewing.
I did revert the test case from this PR, and create a PR to toml-test (toml-lang/toml-test#55).

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.

Black fails to run if pyproject.toml has " }" after a boolean
2 participants