◐ Shell
clean mode source ↗

Fix title() and capitalize() by joshuamegnauth54 · Pull Request #7717 · RustPython/RustPython

@joshuamegnauth54 changed the title Titlecase fixes Fix title() and capitalize()

May 2, 2026

ShaharNaveh

auto-merge was automatically disabled

May 4, 2026 17:10

Head branch was pushed to by a user without write access

ShaharNaveh

auto-merge was automatically disabled

May 6, 2026 18:19

Head branch was pushed to by a user without write access

ShaharNaveh

`icu_casemap` is consistently maintained, official, and tracks the
latest Unicode versions. RustPython is also using other `icu4x` crates,
so using `icu_casemap` is more consistent.

As with islower and isupper, tracking the latest Unicode version is
important because character definitions shift over time which causes
discrepancies between RustPython and CPython.

This commit fixes title().
I dropped unicode-casing because it's cleaner to use icu4x for
everything. `icu4x` will also stay up to date whereas unicode-casing
will need to be periodically updated with new Unicode tables. Dropping
unicode-casing also removes some binary bloat due to the tables.

`capitalize()` mimics CPython behavior more closely now as well.
Notably, I implemented CPython's sigma edge case handler.

joshuamegnauth54 added a commit to joshuamegnauth54/RustPython that referenced this pull request

May 13, 2026
The tests for swapcase() were failing for two reasons. The first is
'𐐧' casing which should be fixed with modern Unicode tables. The second
failure is due to CPython's sigma override, which I implemented in
PR RustPython#7717.

joshuamegnauth54 added a commit to joshuamegnauth54/RustPython that referenced this pull request

May 13, 2026
The tests for swapcase() were failing for two reasons. The first is
'𐐧' casing which should be fixed with modern Unicode tables. The second
failure is due to CPython's sigma override, which I implemented in
PR RustPython#7717.

youknowone pushed a commit that referenced this pull request

May 13, 2026
The tests for swapcase() were failing for two reasons. The first is
'𐐧' casing which should be fixed with modern Unicode tables. The second
failure is due to CPython's sigma override, which I implemented in
PR #7717.