Skip to content

Improve formatnum parserfn#424

Merged
kristian-clausal merged 2 commits into
mainfrom
formatnum
Jul 3, 2026
Merged

Improve formatnum parserfn#424
kristian-clausal merged 2 commits into
mainfrom
formatnum

Conversation

@kristian-clausal

@kristian-clausal kristian-clausal commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Fixes #423

Improvements to formatnum:

  1. Do not format bad input, only allow digits, period and commas
  2. Commas are only allowed with the R "reverse" flag that converts from "formatted" to "raw". Basically it removes commas at its simplest.
  3. Turns out the commas can go anywhere. I wrote a ton of logic that checked that the commas were "correct" in the input, but turns out it doesn't matter at all...

I'll look into localization later in this draft.

This does not implement "alternative" digits, like in South Asian
scripts or West Arabic Numerals, because I didn't find a good
authorative way to do it in Python.

In the current version of Python, there *SHOULD BE*, but isn't
because it's bugged. locale.ALT_DIGITS data (well
locale.ALT_DIGITS is a flag that is used to get the data from
somewhere else...) is broken, and even if it was broken
it contains weird data (the first 0..99 ways to write positive
integers in that script), which doesn't tell us whether the
localization should use those alternative digits when doing
number localization... This needs to be checked later in a
later version of Python, but the whole locale module stuff is
just weird stuff inherited from Posix and C.
@kristian-clausal kristian-clausal marked this pull request as ready for review July 3, 2026 10:18
@kristian-clausal kristian-clausal merged commit bef6782 into main Jul 3, 2026
12 checks passed
@kristian-clausal kristian-clausal deleted the formatnum branch July 3, 2026 10:19
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.

formatnum issue

1 participant