Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

unwrap raises KeyAlreadyPresent for an out-of-order AoT element extension

Aperta
#577 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
python
Ambito
tooling

Direzione di ricerca

Inizia tracciando tomlkit.parse(), doc["y"], doc.unwrap() e il percorso di merge di OutOfOrderTableProxy descritto nell’issue. Riproduci il documento fornito e verifica che l’accesso a y e l’unwrapping non generino più KeyAlreadyPresent, mentre doc.as_string() corrisponda ancora esattamente all’input.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Description

tomlkit.parse() accepts and exactly round-trips this valid document, but accessing doc["y"] or calling doc.unwrap() raises KeyAlreadyPresent: Key "a" already exists:

from tomlkit import parse

content = """\
[[y.a]]
[b.d.x]
[[y.a.c]]
"""

doc = parse(content)
assert doc.as_string() == content
doc.unwrap()  # KeyAlreadyPresent: Key "a" already exists

Python's standard-library tomllib reads it as:

{"y": {"a": [{"c": [{}]}]}, "b": {"d": {"x": {}}}}

The later [[y.a.c]] header extends the last element of the existing y.a array of tables. This works when the parts are adjacent, but an unrelated table makes y out of order. OutOfOrderTableProxy then sees a first as an AoT and later as an implicit Table; its existing fragment merge handles AoT + AoT, but not this AoT + super-table extension.

The example was initially flagged by @chuenchen309 in the description of #565. I reproduced it on current master and narrowed it down to the proxy merge path.

Environment

  • tomlkit 0.15.1 / current master
  • Python 3.12
Lingua principale
Python
Stelle
850
Fork
163
Merge medio
13m
PR unite (30g)
2

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di python-poetry/tomlkit

Tutte le issue di python-poetry/tomlkit

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.