You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
0.15.0 serializes invalid TOML when appending to a parsed inline table #476
In tomlkit 0.15.0, appending a new key to a parsed inline table that already contains multiple key/value pairs can produce invalid TOML: the newly appended key is serialized without a comma separator before it.
This appears to be a regression from 0.14.0.
Reproducer
importtomlkitprint(tomlkit.__version__)
doc=tomlkit.parse('x = { a = 1, b = 2 }\n')
doc['x']['c'] =3out=doc.as_string()
print(out, end='')
tomlkit.parse(out)
Actual behavior on 0.15.0
0.15.0
x = { a = 1, b = 2 c = 3}
Traceback ...
tomlkit.exceptions.UnexpectedCharError: Unexpected character: 'c' at line 1 col 19
The serialized TOML is invalid because the inline table is missing a comma between b = 2 and c = 3.
Expected behavior
as_string() should produce valid TOML, for example:
x = { a = 1, b = 2, c = 3}
The same reproducer works on 0.14.0:
0.14.0
x = { a = 1, b = 2, c = 3}
Environment
Python: 3.13.2
tomlkit: 0.15.0
Last known good version tested: 0.14.0
Notes
This only seems to happen when mutating a parsed inline table with multiple existing entries. Creating/replacing an inline table from scratch still serializes commas correctly.
Activity