toml
toml copied to clipboard
Bug with dotted keys and multi-line strings
Hello,
I suspect there is a bug when parsing multi-line strings in dotted-key tables.
import toml
print(toml.__version__)
print()
toml_data = """
[a]
description = "AAA"
b.description = "BBB"
"""
toml_dict = toml.loads(toml_data)
print(toml_dict["a"]["description"])
print(toml_dict["a"]["b"]["description"])
print()
toml_data = '''
[a]
description = "AAA"
b.description = """
BBB
"""
'''
toml_dict = toml.loads(toml_data)
print(toml_dict["a"]["description"])
print(toml_dict["a"]["b"]["description"])
Gives the output
$ python3 toml_mwe.py
0.10.2
AAA
BBB
BBB
Traceback (most recent call last):
File "toml_mwe.py", line 30, in <module>
print(toml_dict["a"]["b"]["description"])
KeyError: 'description'
Whereas I would expect
AAA
BBB
for both cases.
Just ran into this myself. Anyone know how to fix this? I dug a little into the code around here but it was not clear what (if anything) could be done.
@eugene-bulkin This package does not appear to be maintained anymore. I moved on to use the tomlkit
package instead which has worked well for me: https://pypi.org/project/tomlkit/