Whole file

python-poetry/tomlkit

The author described this change as fix: avoid duplicate table header when adding a key to an out-of-order table (#545). It counts as a record because the check below fails on the code as it stood at 34e51e2d6 and passes on e23a25438, with nothing else changed between the two runs.

Fix saved2026-07-14
Sharing licenceMIT · LICENSE
Change size+12 1

What the code was meant to do, written into the code itself as a save note

fix: avoid duplicate table header when adding a key to an out-of-order table (#545)

The change

11741174 table[key] = value
11751175 break
11761176 else:
1177- self._tables[0][key] = value
1177+ # No part holds a plain value yet, so the chosen part must
1178+ # start rendering its own ``[key]`` header. Prefer a part
1179+ # that is not a super table (it already renders that header):
1180+ # turning a header-less super part concrete here would emit a
1181+ # second, duplicate header next to an existing concrete part
1182+ # and produce TOML that no longer parses.
1183+ for table in self._tables:
1184+ if not table.is_super_table():
1185+ table[key] = value
1186+ break
1187+ else:
1188+ self._tables[0][key] = value
11781189 else:
11791190 self._tables[0][key] = value
11801191 else:

The check that tells the two apart

failpass·tests/test_toml_document.py::test_set_value_on_out_of_order_table_with_empty_concrete_part

Check file tests/test_toml_document.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it34e51e2d6d09af86970f266a4217cea839fdc347
Broken version dated2026-07-14
Moduletomlkit.container
Units changedOutOfOrderTableProxy
Fingerprintb25c97a8d5dc04c3
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in python-poetry/tomlkit