Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

`update()` on an out-of-order table raises `IndexError` after a sub-table fragment was popped

Đang mở
#675 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

@rajmodi8905 đang làm issue này rồi.

Từ ngày 22/10/2026.

  • #677 của @rajmodi8905 — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
68/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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().

Ngôn ngữ chính
Python
Star
861
Fork
201
Merge trung bình
3 ngày 23 giờ
Pull request đã merge (30 ngày)
30

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của python-poetry/tomlkit

Tất cả issue của python-poetry/tomlkit

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.