GeezerVison is showing github.com — Remove redundant `to_owned()` calls by ShaharNaveh · Pull Request #8077 · RustPython/RustPython
Conversation
ShaharNaveh
commented
Jun 11, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
Summary by CodeRabbit
- Refactor
- Simplified internal error-message construction across many modules to reduce unnecessary allocations and improve efficiency; no changes to error text, behavior, or public APIs.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Jun 11, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 81859942-c06c-4e72-9d9b-6f0b47b981fc
📥 Commits
Reviewing files that changed from the base of the PR and between cc33fe9 and 2da4513.
📒 Files selected for processing (18)
crates/capi/src/abstract_.rs
crates/capi/src/unicodeobject.rs
crates/stdlib/src/multiprocessing.rs
crates/stdlib/src/select.rs
crates/stdlib/src/socket.rs
crates/stdlib/src/ssl.rs
crates/vm/src/builtins/code.rs
crates/vm/src/builtins/function.rs
crates/vm/src/builtins/list.rs
crates/vm/src/exceptions.rs
crates/vm/src/function/time.rs
crates/vm/src/stdlib/_signal.rs
crates/vm/src/stdlib/marshal.rs
crates/vm/src/stdlib/nt.rs
crates/vm/src/stdlib/os.rs
crates/vm/src/stdlib/sys.rs
crates/vm/src/stdlib/time.rs
crates/vm/src/vm/mod.rs
✅ Files skipped from review due to trivial changes (11)
- crates/capi/src/abstract_.rs
- crates/vm/src/function/time.rs
- crates/vm/src/stdlib/nt.rs
- crates/stdlib/src/ssl.rs
- crates/vm/src/stdlib/sys.rs
- crates/vm/src/stdlib/os.rs
- crates/stdlib/src/multiprocessing.rs
- crates/vm/src/builtins/list.rs
- crates/vm/src/stdlib/marshal.rs
- crates/stdlib/src/socket.rs
- crates/vm/src/stdlib/_signal.rs
🚧 Files skipped from review as they are similar to previous changes (5)
- crates/vm/src/vm/mod.rs
- crates/vm/src/exceptions.rs
- crates/stdlib/src/select.rs
- crates/vm/src/builtins/code.rs
- crates/vm/src/stdlib/time.rs
📝 Walkthrough
Walkthrough
This PR replaces many small constant error-message allocations with direct string literals passed to VM error constructors across multiple modules, without changing error texts or control flow.
Changes
Error message string literal optimizations
| Layer / File(s) |
Summary |
CAPI error construction simplification crates/capi/src/abstract_.rs, crates/capi/src/unicodeobject.rs |
C API boundary functions now pass error messages as string literals to vm.new_system_error and vm.new_type_error, removing .to_owned() allocations. |
Stdlib error simplifications crates/stdlib/src/multiprocessing.rs, crates/stdlib/src/select.rs, crates/stdlib/src/socket.rs, crates/stdlib/src/ssl.rs |
Multiprocessing timeout, epoll flags validation, many socket/address/service/protocol lookup and validation paths, and SSL recv-result validation now construct OS errors from string literals without temporary allocations. |
VM builtins error optimizations crates/vm/src/builtins/code.rs, crates/vm/src/builtins/function.rs, crates/vm/src/builtins/list.rs, crates/vm/src/exceptions.rs, crates/vm/src/function/time.rs |
Code object loading, bound-method validation, list assignment index errors, syntax-error slot validation, and timeout NaN validation now use string literals directly in error constructors. |
VM stdlib module error simplifications crates/vm/src/stdlib/_signal.rs, crates/vm/src/stdlib/marshal.rs, crates/vm/src/stdlib/nt.rs, crates/vm/src/stdlib/os.rs, crates/vm/src/stdlib/sys.rs, crates/vm/src/stdlib/time.rs |
Signal setup, marshal validation (multiple cases), NT getlogin, OS timing/loadavg, sandbox I/O errors, and platform-specific time functions now eliminate temporary string allocations in error construction. |
VM core initialization error optimization crates/vm/src/vm/mod.rs |
VM initialization's callable cache error now passes the message as a string literal to vm.new_runtime_error. |
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~8 minutes
Possibly related PRs
Suggested reviewers
- youknowone
- bschoenmaeckers
Poem
🐇 I nibble at strings with swift delight,
I swap owned crumbs for literals light,
No heap to dig, no clutter in the burrow,
Errors hop tidy, the code runs thorough,
A happy rabbit, keeping builds bright.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name |
Status |
Explanation |
Resolution |
| Docstring Coverage |
⚠️ Warning |
Docstring coverage is 77.27% which is insufficient. The required threshold is 80.00%. |
Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (4 passed)
| Check name |
Status |
Explanation |
| Description Check |
✅ Passed |
Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check |
✅ Passed |
The title 'Remove redundant to_owned() calls' clearly summarizes the main change across all modified files, which consistently replace .to_owned() allocations with direct string literal references. |
| Linked Issues check |
✅ Passed |
Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check |
✅ Passed |
Check skipped because no linked issues were found for this pull request. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
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.
❤️ Share
Comment @coderabbitai help to get the list of available commands and usage tips.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|