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

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

Open
pwwang opened this issue Nov 12, 2021 · 1 comment
Open

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

pwwang opened this issue Nov 12, 2021 · 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

@pwwang
Copy link

pwwang commented Nov 12, 2021

>>> 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']}
@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
@mustafa0x
Copy link

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.

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