Skip to content

tomlkit 0.15.1 fails on out-of-order table header #632

Done

Description

@tiran

tomlkit 0.15.1 and earlier fail to parse out-of-order table header. The following example is valid TOML and loads fine with stdlib tomllib.

import tomllib, tomlkit

doc = """\
[a]
b.c = 1
b.d = 2

[x]
y = 1

[a.b.e]
f = 3
"""

tomllib.loads(doc)   # OK
tomlkit.loads(doc)   # ParseError: Key "b" already exists. at line 9 col 0

We noticed this problem while parsing the pyproject.toml file of geventhttpclient-2.5.0 https://raw.githubusercontent.com/geventhttpclient/geventhttpclient/refs/tags/2.5.0/pyproject.toml . See python-wheel-build/fromager#1356

Activity

  1. lidongze1002 commented on Nov 17, 2026

    @lidongze1002

    Ran into this while looking at out-of-order table handling.

    It looks like #572 already covers it. I applied that PR's patch on top of current master and this document parses, giving {'c': 1, 'd': 2, 'e': {'f': 3}} under a.b, with the rest of the suite passing (770 passed, excluding tests/test_toml_tests.py, which needs the toml-test submodule checked out).

    So if #572 lands, this can close with it rather than with a separate patch — the _validate_table_candidate change there is what stops the KeyAlreadyPresent when the key reads back as an OutOfOrderTableProxy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions