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

Can't parse multiline #237

Open
simplesteph opened this issue Mar 9, 2019 · 1 comment
Open

Can't parse multiline #237

simplesteph opened this issue Mar 9, 2019 · 1 comment
Labels
component: decoder Related to parsing in `toml.load` syntax: strings Related to string literals type: bug A confirmed bug or unintended behavior

Comments

@simplesteph
Copy link

simplesteph commented Mar 9, 2019

The issue is with the ' character I believe, but it can't fix it on my end. Ensure how this is buggy? The parser seems to have issues separating the two q1 and q2

import toml

toml.loads('''
[q1]
Explanation = """
co "foo"
"He's" 
"""

[q2]
Explanation = """
co- "Lambda 's"
"""
''')

fails with error:

Traceback (most recent call last):
  File "/Users/stephanemaarek/.pyenv/versions/3.6.5/lib/python3.6/site-packages/toml/decoder.py", line 340, in loads
    value, vtype = decoder.load_value(multilinestr)
  File "/Users/stephanemaarek/.pyenv/versions/3.6.5/lib/python3.6/site-packages/toml/decoder.py", line 772, in load_value
    raise ValueError("Stuff after closed string. WTF?")
ValueError: Stuff after closed string. WTF?

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/stephanemaarek/projects/gitlab/udemy-automation-python/practice_exams/test.py", line 14, in <module>
    ''')
  File "/Users/stephanemaarek/.pyenv/versions/3.6.5/lib/python3.6/site-packages/toml/decoder.py", line 342, in loads
    raise TomlDecodeError(str(err), original, pos)
toml.decoder.TomlDecodeError: Stuff after closed string. WTF? (line 11 column 1 char 85)
@simplesteph
Copy link
Author

simplesteph commented Mar 9, 2019

Note that if it's replaced by (removed co "foo"), then we fall under the case of #230

import toml

toml.loads('''
[q1]
Explanation = """
"He's" 
"""

[q2]
Explanation = """
co- "Lambda 's"
"""
''')

error

Traceback (most recent call last):
  File "/Users/stephanemaarek/projects/gitlab/udemy-automation-python/practice_exams/test.py", line 14, in <module>
    ''')
  File "/Users/stephanemaarek/.pyenv/versions/3.6.5/lib/python3.6/site-packages/toml/decoder.py", line 301, in loads
    raise TomlDecodeError("Unbalanced quotes", original, i)
toml.decoder.TomlDecodeError: Unbalanced quotes (line 5 column 8 char 22)

Repository owner deleted a comment from epheien Jun 18, 2019
Repository owner deleted a comment from simplesteph Jun 18, 2019
@uiri uiri reopened this Jun 19, 2019
@pradyunsg pradyunsg added type: bug A confirmed bug or unintended behavior component: decoder Related to parsing in `toml.load` syntax: strings Related to string literals labels Apr 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: decoder Related to parsing in `toml.load` syntax: strings Related to string literals type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

No branches or pull requests

3 participants