`update()` on an out-of-order table raises `IndexError` after a sub-table fragment was popped
维护者通常 2 天内回复
评估
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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().
- 主要语言
- Python
- 星标
- 861
- 派生
- 201
- 平均合并
- 3 天 22 小时
- 30 天内合并 PR
- 32
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
python-poetry/tomlkit 的其他 Issue
-
Speed up array appends可能已有人在做 @harshitgupta31415 于 12 天前认领。 未关闭
难度 4/5 1-2 天 新手友好度 42/100
python-poetry/tomlkit#665 ·
维护者通常 2 天内回复
-
Deleting the last key under a dotted key in an inline table produces invalid TOML可能已有人在做 @cig13zs 于 12 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 62/100
python-poetry/tomlkit#662 ·
维护者通常 2 天内回复
-
AttributeError on an out-of-order table under an indented header (4+ levels)可能已有人在做 @cig13zs 于 12 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 18/100
python-poetry/tomlkit#661 ·
维护者通常 2 天内回复
-
In-place array repetition changes values without updating serialized TOML可能已有人在做 @harbinresearcher 于 15 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 35/100
python-poetry/tomlkit#646 · 1 条评论 ·
维护者通常 2 天内回复
-
tomlkit 0.15.1 fails on out-of-order table header可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 4/5 3-5 天 新手友好度 45/100
python-poetry/tomlkit#632 ·
维护者通常 2 天内回复
查看 python-poetry/tomlkit 的全部 Issue
相似的 Issue
-
backlog
难度 1/5 1 小时以内 新手友好度 91/100
EchoTools/nevr-runtime#1108 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
btclib-org/btclib-wallet#587 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
documentation
难度 2/5 1-3 小时 新手友好度 68/100
Judgment-Pack/judgment-pack-spec#275 ·
维护者通常 1 天内回复