◐ Shell
clean mode source ↗

Fix swapcase() by joshuamegnauth54 · Pull Request #7788 · RustPython/RustPython

Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/vm/src/builtins/str.rs`:
- Around line 1664-1676: In swapcase_utf8, don’t treat every non-uppercase char
as lowercase; instead preserve titlecase and other uncased characters. Change
the branching so that if ch.is_uppercase() you call lowercase_or_sigma(ch, s, i,
out); else if ch.is_lowercase() you perform the to_uppercase() path and write
the uppercase bytes to out. For the remaining case (neither is_uppercase nor
is_lowercase, e.g. titlecase, digits, punctuation) copy the original char’s
UTF‑8 bytes into out unchanged. This touches swapcase_utf8 and reuses
lowercase_or_sigma for the uppercase->lowercase work.