toml icon indicating copy to clipboard operation
toml copied to clipboard

Multiple-line strings don't get escaped when a TOML format included

Open pwwang opened this issue 3 years ago • 1 comments

>>> import toml
>>> import tomlkit
>>> s = """
... string = ['''
... [item]
... a = 1
... ''', '''
... [item]
... a = 2
... ''']
... """
>>> toml.loads(s)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    toml.loads(s)
  File "/.../lib/python3.9/site-packages/toml/decoder.py", line 514, in loads
    raise TomlDecodeError(str(err), original, pos)
toml.decoder.TomlDecodeError: Duplicate keys! (line 7 column 1 char 44)
>>> tomlkit.parse(s)
{'string': ['[item]\na = 1\n', '[item]\na = 2\n']}

pwwang avatar Nov 12 '21 02:11 pwwang

another bug:

In [1]: import toml

In [2]: s = """
   ...: about = '''
   ...: hi
   ...: 
   ...:    - Hello world's hello
   ...: 
   ...: ## hello hello hello hello hello hello
   ...: '''
   ...: """
   ...: 

In [3]: print(toml.loads(s)['about'])
hi

   - Hello world's hello

This library should have a warning that it shouldn't be used.

mustafa0x avatar Dec 06 '22 02:12 mustafa0x