toml icon indicating copy to clipboard operation
toml copied to clipboard

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

Open seperman opened this issue 4 years ago • 7 comments

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 avatar Oct 07 '20 01:10 seperman

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

markman123 avatar Oct 15 '20 23:10 markman123

Awesome! Thanks

On Oct 15, 2020, at 5:23 PM, markman123 [email protected] wrote:

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

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

seperman avatar Oct 16 '20 02:10 seperman

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.

ZeroKnight avatar Oct 29 '20 10:10 ZeroKnight

I was hit by this as well.

velit avatar Jan 08 '21 19:01 velit

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

seperman avatar Oct 05 '21 02:10 seperman

This hit me too - thanks for the workaround @ZeroKnight

anthonyjb avatar Jul 14 '22 23:07 anthonyjb

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)

seperman avatar Oct 17 '22 06:10 seperman