`update()` on an out-of-order table raises `IndexError` after a sub-table fragment was popped
Maintainer antworten meist innerhalb von 2 Tagen
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 68/100
Rechercherichtung
Start with the reproduced tomlkit call in the issue and inspect tomlkit/container.py around __setitem__ line 1262, where the traceback indexes _tables. Compare the failing update() call with setting the same keys individually after pop. Done means the update no longer raises IndexError and the document can be dumped as expected.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Versions tested: tomlkit 0.15.2 from PyPI (the newest release on 2026-10-21) and the master branch at
eddd27e43a62fe58707c311bfad2f52e72493f53 (its head on 2026-10-21); Python 3.11.10 on Linux.
Reproduce (one command):
python3 -c '
import tomlkit
doc = tomlkit.parse("[y.y.b]\nc = 1\n[y]\nd = 1\n[y.b]\ne = 2\n[y.y]\n")
doc["y"]["y"].pop("b")
doc["y"].update({"y": [{"z": 1}], "b": {"e": -0.5}})
print(tomlkit.dumps(doc))
'
The document is valid TOML: tomllib.loads reads it as {'y': {'y': {'b': {'c': 1}}, 'd': 1, 'b': {'e': 2}}}.
Expected: the update succeeds and the document can be dumped.
Observed (the same on both versions):
File ".../tomlkit/container.py", line 1262, in __setitem__
old_value = self._tables[map_indices[0]][key]
~~~~~~~~~~~~^^^^^^^^^^^^^^^^
IndexError: list index out of range
Setting the two keys one at a time (doc["y"]["y"] = [{"z": 1}], then doc["y"]["b"] = {"e": -0.5}) after the same pop does not
raise. We have not looked for the cause.
Found while testing tomlkit's editing API against the standard library's tomllib with generated documents.
Possibly related: #196 (out-of-order sections), though that report is about _insert_after, not update().
- Vorherrschende Sprache
- Python
- Sterne
- 864
- Forks
- 207
- Ø Merge
- 4 T. 10 Std.
- Gemergte PRs (30 T.)
- 30
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Kein Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus python-poetry/tomlkit
-
Deleting the last key under a dotted key in an inline table produces invalid TOMLEvtl. vergeben @cig13zs hat das vor 15 Tagen übernommen. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 62/100
python-poetry/tomlkit#662 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
AttributeError on an out-of-order table under an indented header (4+ levels)Evtl. vergeben @cig13zs hat das vor 15 Tagen übernommen. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 18/100
python-poetry/tomlkit#661 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
In-place array repetition changes values without updating serialized TOMLEvtl. vergeben @harbinresearcher hat das vor 18 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 35/100
python-poetry/tomlkit#646 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 2 Tagen
-
tomlkit 0.15.1 fails on out-of-order table headerEvtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
python-poetry/tomlkit#632 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
`dumps(sort_keys=True)` only sorts the top level of a parsed document (nested tables / inline tables / AoT keep original order)Evtl. vergeben @Sreekant13 hat das vor 31 Tagen übernommen. Offen
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
python-poetry/tomlkit#614 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 2 Tagen
Alle Issues in python-poetry/tomlkit
Ähnliche Issues
-
infrastructure
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
NatLabRockies/H2Integrate#977 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
topoteretes/cognee#6470 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
-
area:docs priority:p2 type:docs wave:9
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 84/100
jejjohnson/radtrax#293 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug core plugins
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
bunkerity/bunkerweb#4121 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag