Skip to content

Invalid serialization after assigning InlineTable #414

@Mrmaxmeier

Description

@Mrmaxmeier

Hi,

I've encountered an invalid TOML document after modifying and inserting an InlineTable.
Here's an example -- the resulting document is invalid since it declares the [foo] table twice:

>>> from tomlkit import parse, inline_table
>>> doc = parse("""[foo.bar]
... here = true
... 
... [foo]
... a = 1
... b = 2
... """)
>>> doc["foo"]["bar"] = inline_table()
>>> doc["foo"]["bar"].update({"a": "b"})
>>> print(doc.as_string())
[foo]
bar = {a = "b"}
[foo]
a = 1
b = 2
>>> parse(doc.as_string())
tomlkit.exceptions.ParseError: Key "foo" already exists. at line 5 col 0

This behavior doesn't happen with normal non-inline tables and can also be worked around by round-tripping to JSON since the dotted table syntax is a prerequisite for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions