◐ Shell
clean mode source ↗

fix: Swapcase must handle multibyte expansions by joshuamegnauth54 · Pull Request #7559 · RustPython/RustPython

Skip to content

Navigation Menu

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

Conversation

coderabbitai[bot]

youknowone

ShaharNaveh

`swapcase` used `to_ascii_lowercase` and uppercase to swap cases. This
is fine for ASCII, but code points may expand into multiple bytes which
leads to incorrect case swaps for some languages. The fix is to use
`to_lowercase` and `to_uppercase` instead.

Unfortunately, this leads to a realloc in `swapcase` when bytes are
expanded.

Part of RustPython#7526.

ShaharNaveh

youknowone

This was referenced

May 9, 2026