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

bug: comma in list's value is not parsed properly #322

Open
seperman opened this issue Oct 7, 2020 · 7 comments
Open

bug: comma in list's value is not parsed properly #322

seperman opened this issue Oct 7, 2020 · 7 comments
Labels
component: decoder Related to parsing in `toml.load` syntax: arrays Related to arrays type: bug A confirmed bug or unintended behavior

Comments

@seperman
Copy link

seperman commented Oct 7, 2020

toml==0.10.1

>>> import toml
>>> toml_string = """
... a=[',', '']
... """
>>> toml.loads(toml_string)
{'a': ['', '', '']}

So the result's list's length is 3 instead of 2.

@seperman seperman changed the title comma in list's value is not parsed properly bug: comma in list's value is not parsed properly Oct 7, 2020
@markman123
Copy link

This is the offending line:
https://github.com/uiri/toml/blob/master/toml/decoder.py#L946
Working on a pull request now

@seperman
Copy link
Author

seperman commented Oct 16, 2020 via email

@ZeroKnight
Copy link

ZeroKnight commented Oct 29, 2020

In the meantime, it's possible to work around this with unicode escapes:

my_list = [
    "Hello\u002C World!",
    "Lovely day\u002C isn't it?"
]

It's not pretty, but it works.

@velit
Copy link

velit commented Jan 8, 2021

I was hit by this as well.

@seperman
Copy link
Author

seperman commented Oct 5, 2021

Hey @uiri
It is the anniversary of this ticket. Any updates?
Best

@pradyunsg pradyunsg added type: bug A confirmed bug or unintended behavior component: decoder Related to parsing in `toml.load` syntax: arrays Related to arrays labels Apr 20, 2022
@anthonyjb
Copy link

This hit me too - thanks for the workaround @ZeroKnight

@seperman
Copy link
Author

seperman commented Oct 17, 2022

By the way, I have stopped using this library. pip comes with a toml parser! And it doesn't have this annoying bug.

from pip._vendor import tomli
tomli.loads(contents)

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: arrays Related to arrays type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

No branches or pull requests

6 participants