Emptying a nested array of tables before an out-of-order super-table renders invalid TOML (0.15.2, since #567)
Mantenedores costumam responder em até 2 dias
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 45/100
Direção de pesquisa
Start by running the reproduction in the issue: parse the [[a.b.c]] document, pop the element, and inspect the tomlkit.dumps output. The bug is in how an emptied array of tables is rendered when its super-table comes later in the document, which #567 changed; the issue says the parent commit of #567 produces valid output. Done when the output parses with both tomlkit.parse and tomllib.loads to {'a': {'b': {'c': []}, 'y': 1}}.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Versions tested: tomlkit 0.15.2 (tag a0b15eb), and master at d7def7d (2026-10-29); Python 3.12.
Reproduce:
import tomlkit
doc = tomlkit.parse("[[a.b.c]]\nx = 1\n\n[a]\ny = 1\n")
doc["a"]["b"]["c"].pop()
out = tomlkit.dumps(doc)
print(repr(out))
tomlkit.parse(out)
The input is valid TOML, and tomlkit parses it to {'a': {'b': {'c': [{'x': 1}]}, 'y': 1}}. After the pop, doc.unwrap() is {'a': {'b': {'c': []}, 'y': 1}}, as expected.
Observed: dumps returns 'a.b.c = []\n[a]\ny = 1\n', which declares a twice:
tomlkit.exceptions.ParseError: Redefinition of an existing table at line 3 col 0
tomllib.loads rejects it too: Cannot declare ('a',) twice (at line 2, column 3).
Expected: output that parses back to {'a': {'b': {'c': []}, 'y': 1}}, for example what tomlkit.dumps(doc.unwrap()) returns:
[a]
y = 1
[a.b]
c = []
Where it comes from: #567 renders an emptied array of tables as key = []. When the array sits under a super-table that is defined later in the document, the dotted key is emitted where the [[a.b.c]] header was, before [a]. On the parent commit of #567, the same steps produce output that parses. The same happens when [a] extends a.b with a dotted key, for example [[a.b.c]]\nx = 1\n[a]\nb.z = 1\n.
Related: #553, which #567 addressed in part, and #675, another failure after removing an element from an out-of-order table.
This came up while running generated tests on pairs of tomlkit pull requests that were open at the same time (#565 and #567). The reproduction above gives the same output on 0.15.2 and on master.
- Linguagem predominante
- Python
- Estrelas
- 867
- Forks
- 220
- Merge médio
- 3d 22h
- PRs com merge (30d)
- 25
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Sem guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de python-poetry/tomlkit
-
`update()` on an out-of-order table raises `IndexError` after a sub-table fragment was poppedTalvez já em andamento @rajmodi8905 assumiu há 14 dias. Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 68/100
python-poetry/tomlkit#675 · 3 comentários ·
Mantenedores costumam responder em até 2 dias
-
AttributeError on an out-of-order table under an indented header (4+ levels)Talvez já em andamento @cig13zs assumiu há 21 dias. Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 18/100
python-poetry/tomlkit#661 ·
Mantenedores costumam responder em até 2 dias
-
In-place array repetition changes values without updating serialized TOMLTalvez já em andamento @harbinresearcher assumiu há 24 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 35/100
python-poetry/tomlkit#646 · 1 comentário ·
Mantenedores costumam responder em até 2 dias
-
tomlkit 0.15.1 fails on out-of-order table headerTalvez livre de novo Um pull request para esta issue foi fechado sem ser mesclado. Aberta
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 45/100
python-poetry/tomlkit#632 ·
Mantenedores costumam responder em até 2 dias
-
`dumps(sort_keys=True)` only sorts the top level of a parsed document (nested tables / inline tables / AoT keep original order)Talvez já em andamento @Sreekant13 assumiu há 37 dias. Aberta
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 35/100
python-poetry/tomlkit#614 · 2 comentários ·
Mantenedores costumam responder em até 2 dias
Todas as issues de python-poetry/tomlkit
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 64/100
its-me-prash/vwgroup-connect-ha#2019 ·
Mantenedores costumam responder em até 1 dia
-
bug good first issue
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 86/100
KonstantinStarovoytov/kitden#21 ·
Mantenedores costumam responder em até 1 dia
-
RefactorAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
ehmatthes/gh-profiler#166 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
smart-on-fhir/smart-fetch#73 ·
-
good first issue help wanted
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 85/100
RizgarOzan/playcal#13 ·