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

Parsing breaks when adding a closing bracket in a quoted key #74

Closed
spapanik opened this issue Feb 25, 2020 · 0 comments · Fixed by #76
Closed

Parsing breaks when adding a closing bracket in a quoted key #74

spapanik opened this issue Feb 25, 2020 · 0 comments · Fixed by #76

Comments

@spapanik
Copy link

parsing breaks when the quoted key contains a closing bracket.

>>> import tomlkit
>>> tomlkit.parse("""
... ["["]
... foo = 1
... """)
{'[': {'foo': 1}}

>>> tomlkit.parse("""
... ["]"]
... foo = 1
... """)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/stephanos/.local/share/virtualenvs/tomlkit/lib/python3.8/site-packages/tomlkit/api.py", line 51, in parse
    return Parser(string).parse()
  File "/home/stephanos/.local/share/virtualenvs/tomlkit/lib/python3.8/site-packages/tomlkit/parser.py", line 153, in parse
    key, value = self._parse_table()
  File "/home/stephanos/.local/share/virtualenvs/tomlkit/lib/python3.8/site-packages/tomlkit/parser.py", line 946, in _parse_table
    cws, comment, trail = self._parse_comment_trail()
  File "/home/stephanos/.local/share/virtualenvs/tomlkit/lib/python3.8/site-packages/tomlkit/parser.py", line 314, in _parse_comment_trail
    raise self.parse_error(UnexpectedCharError, c)
tomlkit.exceptions.UnexpectedCharError: Unexpected character: '"' at line 2 col 3
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 a pull request may close this issue.

1 participant