Skip to content

fix: reject non-ASCII digits in numbers - #686

Closed
Vansh8803 wants to merge 1 commit into
python-poetry:masterfrom
Vansh8803:fix/reject-non-ascii-digits-in-numbers
Closed

Vansh8803 wants to merge 1 commit into
python-poetry:masterfrom
Vansh8803:fix/reject-non-ascii-digits-in-numbers

Conversation

@Vansh8803

Copy link
Copy Markdown

tomlkit accepts non-ASCII Unicode digits in numbers because int() and float() convert them. A token like 1 followed by U+0660 (Arabic-Indic digit zero) parses to 10 instead of being rejected, so an invalid document is read as a valid one with the wrong value. This requires the cleaned numeric token to be ASCII before conversion, raising InvalidNumberError otherwise. Adds a regression test; existing tests still pass.

@dimbleby

Copy link
Copy Markdown
Contributor

Explain why not #676

@Vansh8803

Copy link
Copy Markdown
Author

Explain why not #676

Thanks, I hadn't seen #676. It predates this and is more complete: it also rejects
embedded whitespace in numbers (such as a vertical tab), which I left out here. If any of the regression cases here are useful,
they are easy to fold into that PR, but #676 looks like the better fix to take.

@Vansh8803 Vansh8803 closed this Oct 26, 2026
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.

2 participants