Skip to content

tomllib: error when reading dicts with carriage returns or trailing commas #153843

Description

@lorcap

Bug report

Bug description:

The following snippet throws a tomllib.TOMLDecodeError: Invalid initial character for a key part (at line 1, column 6):

import tomllib

tomllib.loads("""\
A = {
  a = 1,
}
""")

The following throws a tomllib.TOMLDecodeError: Invalid initial character for a key part (at line 1, column 14):

import tomllib

tomllib.loads("""\
A = { a = 1, }
""")

The same snippets run fine with tomli-2.4.1 installed via pip in the same virtual environment.

CPython versions tested on:

3.14

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions