toml
toml copied to clipboard
Incorrect toml.dumps() value when "\\x" is present in the string
Current behavior:
>>> toml.dumps({ 'val': 'win32\\path\\x64\\file.txt'})
'val = "win32\\path\\x64\\\\file.txt"\n' # note the \\\\ after x64
Correct behavior:
toml.dumps({ 'val': 'win32\\path\\x64\\file.txt'})
'val = "win32\\path\\x64\\file.txt"\n'
I suspect the bug occurs somewhere here: https://github.com/uiri/toml/blob/master/toml/encoder.py#L98
This dirty fix appears to work, but I'm not 100% sure that it won't break anything else:
#v = v.split("\\x")
v = re.split(r'(?<!\\)\\x', v)
Possibly linked with https://github.com/uiri/toml/issues/201