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

Broken parsing of triple-quoted strings in arrays #123

Open
bugreport1234 opened this issue Sep 7, 2017 · 7 comments
Open

Broken parsing of triple-quoted strings in arrays #123

bugreport1234 opened this issue Sep 7, 2017 · 7 comments
Labels
component: decoder Related to parsing in `toml.load` syntax: strings Related to string literals type: bug A confirmed bug or unintended behavior

Comments

@bugreport1234
Copy link

I've got a toml file like this:

x=["""hello
world"""]

This looks like valid toml to me. However parsing it with the library gives the result:

>>> with open("test.toml") as file:
...     x = toml.load(file)
...
>>> x
{'x': ['h']}

It seems the string is just completely cut off after the first character. Changing the string content sometimes results in other cutoffs:

x=["""this is a test
"""]

results in:

{'x': ['this is a ']}

I'm using Python 3.6.1 and toml github master on windows.

@uiri
Copy link
Owner

uiri commented Sep 10, 2017

Hi,

Thank you for the bug report. I think this is a duplicate of #113. Do you still get this issue with Python on Windows if you use Unix (\n) rather than Windows/DOS (\r\n) linebreaks?

@bugreport1234
Copy link
Author

Yes, replacing \r\n with \n (or even just \r) doesn't change the output, the string is still cut off.

@bugreport1234
Copy link
Author

I also just tested this on linux, and get the same bug, the string is cut off as well.

@uiri uiri added the bug label Sep 26, 2017
@uiri
Copy link
Owner

uiri commented Sep 26, 2017

Cool. I've verified this bug. Arrays don't seem to like multiline strings.

@gaborbernat
Copy link

@uiri any plan to fix this?

@JulienPalard
Copy link

I can reproduce it with toml 0.10.0:

>>> toml.loads('foo=["""foo\nbar"""]')
{'foo': ['']}

@rudy-6-4
Copy link

rudy-6-4 commented May 7, 2020

Could be linked to #204, but the fix '#293' for #204 will not work on this case.

@pradyunsg pradyunsg added type: bug A confirmed bug or unintended behavior and removed bug labels Mar 13, 2022
@pradyunsg pradyunsg added 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

6 participants