Fix swapcase()#7788
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds a crate-local ASCII swapcase helper, makes bytes swapcase delegate to it, imports helpers into str.rs, and refactors PyStr::swapcase to dispatch by encoding kind with a new UTF‑8-aware swapcase routine. ChangesSwapcase refactoring with per-kind helpers
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
📦 Library DependenciesThe following Lib/ modules were modified. Here are their dependencies: [x] test: cpython/Lib/test/test_str.py (TODO: 7) dependencies: dependent tests: (no tests depend on str) Legend:
|
36c57da to
e4ba68f
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
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.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 06ccac61-207a-4696-bbb2-271a962b34f6
⛔ Files ignored due to path filters (1)
Lib/test/test_str.pyis excluded by!Lib/**
📒 Files selected for processing (2)
crates/vm/src/builtins/str.rscrates/vm/src/bytes_inner.rs
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.
e4ba68f to
b7ad7c4
Compare
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 #7117.
This should work after rebasing, so I'm opening it as a placeholder for now. 😸Ready since #7117 is merged.Summary by CodeRabbit