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.
Projectpython-poetry/tomlkit
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
| 1174 | 1174 | table[key] = value | |
| 1175 | 1175 | break | |
| 1176 | 1176 | 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 | |
| 1178 | 1189 | else: | |
| 1179 | 1190 | self._tables[0][key] = value | |
| 1180 | 1191 | else: |
The check that tells the two apart
fail→pass·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
- 2026-07-15Fix top-level scalar captured by a table rendered from a dotted key (#550)
- 2026-07-14Fix array of tables replacing a dotted key swallowing the next sibling (#542) (#549)
- 2026-06-23fix: keep newline after dotted inline table (#533)
- 2026-06-23fix: reject out-of-order concrete+super table redefinitions at parse time (#530)
- 2026-06-23raise on malformed array element instead of dropping it (#527)
- 2026-06-23Fix ParseError when a sub-table extends an array of tables out of order (#498)