Skip to content

Parse nonfinite numbers inside inline tables - #464

Open
rupayon123 wants to merge 1 commit into
uiri:masterfrom
rupayon123:fix/inline-nonfinite-values-20260924
Open

rupayon123 wants to merge 1 commit into
uiri:masterfrom
rupayon123:fix/inline-nonfinite-values-20260924

Conversation

@rupayon123

Copy link
Copy Markdown

Problem

toml.loads('t = {n = inf}') and the equivalent nan, +inf, and +nan inline values fail as invalid inline-table values, while the same numeric values parse in regular tables (#403). The inline-table gate also rejects a leading + on ordinary numbers.

Change

Let the inline gate pass the nonfinite spellings and positive numeric prefix through to the existing numeric parser. A parameterized regression checks the inline result against regular-table parsing for seven forms.

Validation

  • New regression: 5 of 7 cases failed before the fix; all 7 pass afterward.
  • pytest -q tests/test_api.py — 29 passed, 2 skipped.
  • The seven cases agree with Python 3.12 tomllib.
  • python3.12 -m compileall -q toml tests, git diff --check, and Flake8 on toml/decoder.py passed. Flake8 on the test file passed with E501 excluded; it has a pre-existing 84-character line at line 23.

A broad pytest -q collection attempt stopped on the existing stdin-based tests/encoding_test.py harness. No full conformance suite was run. Prepared with AI assistance.

Fixes #403.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inline tables with inf/nan as values fail to parse

1 participant