Skip to content

Fix corrupt output when adding to a dotted key inside an inline table#500

Merged
frostming merged 1 commit into
python-poetry:masterfrom
gaoflow:fix/495-dotted-key-inline-table
Jun 11, 2026
Merged

Fix corrupt output when adding to a dotted key inside an inline table#500
frostming merged 1 commit into
python-poetry:masterfrom
gaoflow:fix/495-dotted-key-inline-table

Conversation

@gaoflow

@gaoflow gaoflow commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Adding a key to a dotted-key table inside an inline table produced unparseable output (#495):

doc = parse('a = {b.c = 1}\n')
doc["a"]["b"]["d"] = 2
doc.as_string()  # 'a = {b.c = 1d = 2\n}'

InlineTable.as_string rendered the dotted prefix once and then dumped the materialized table's block-style body verbatim. The fix renders one prefix.child = value pair per child (recursing for nested dotted keys), mirroring what Container._render_table does for dotted keys in regular tables, so the result is a = {b.c = 1, b.d = 2}. Repeating the prefix is required for correctness: rendering the new key bare ({b.c = 1, d = 2}) would change its meaning to a.d.

Fixes #495.

@gaoflow
gaoflow force-pushed the fix/495-dotted-key-inline-table branch from 2fa536b to 9c4694c Compare June 10, 2026 04:12
@frostming
frostming merged commit a076a6a into python-poetry:master Jun 11, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

adding to a dotted inline table produces corrupt output

2 participants