Skip to content

Preserve Unicode casefold keys when IGNORECASE and LOWERCASEFIRST are combined - #211

Open
rupayon123 wants to merge 1 commit into
SethMMorton:mainfrom
rupayon123:fix/ignorecase-lowercasefirst-20261027
Open

rupayon123 wants to merge 1 commit into
SethMMorton:mainfrom
rupayon123:fix/ignorecase-lowercasefirst-20261027

Conversation

@rupayon123

Copy link
Copy Markdown

LOWERCASEFIRST is documented as having no effect with IGNORECASE, but the combination currently changes Unicode keys. For example, dotless ı is swapped to I and then casefolded to i, making it compare equal to ASCII i and changing the sorted order.

Apply casefold directly when IGNORECASE is set; keep case swapping in the case-sensitive branch. Public regressions cover dotless i, long s, ASCII, forward/reverse ordering, paths and compatibility normalization. The internal transform expectation is updated to match the documented contract.

On macOS arm64/Python 3.12.15, all 389 tests pass with both the pure Python and fastnumbers 5.2.0 backends. Doctests, strict mypy, formatting, package builds and twine checks pass. Ruff 0.17.3 reports the same 39 existing diagnostics on unchanged main and this patch, with none introduced. Other Python/OS combinations and PyICU were not run locally.

@agammann agammann left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed the case-transform branch at ac19fa6. With IGNORECASE set, applying casefold directly prevents LOWERCASEFIRST and the internal locale swap from changing Unicode comparison keys. The focused transform, key, and sorting tests pass locally (43 tests on Python 3.14.8), including dotless i and long s across PATH and normalization modes. I did not run the full platform or optional PyICU matrix.

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