| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
📝 Walkthrough
WalkthroughRefactors object pickling/reduction to add a new reduce_newobj path and helpers for extracting getnewargs/getstate/slot and item data, adds getstate/setstate to IO wrapper classes for pickling, interns getnewargs_ex in VM context, and removes a legacy Python reducelib module. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested reviewers
Poem🚥 Pre-merge checks | ✅ 3 ✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review details Configuration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro 📥 CommitsReviewing files that changed from the base of the PR and between 8c5d1dd and a418c68. ⛔ Files ignored due to path filters (11)
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
crates/vm/src/stdlib/io.rs (5)crates/vm/src/stdlib/thread.rs (1) ✏️ Tip: You can disable this entire section by setting review_details to false in your review settings. 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. ❤️ ShareComment @coderabbitai help to get the list of available commands and usage tips. |
Sorry, something went wrong.
|
Code has been automatically formatted The code in this PR has been formatted using:
git pull origin pickle |
Sorry, something went wrong.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agentsIn `@crates/vm/src/stdlib/io.rs`: - Around line 4105-4140: The StringIO __setstate__ method is missing the closed-file guard present in BytesIO.__setstate__; add a check at the top of fn __setstate__(zelf: PyRef<Self>, ...) that tests zelf.closed.load() and returns the same error used by BytesIO.__setstate__ when the object is closed (use the same vm error construction so behavior and message match). Ensure this check runs before mutating self.buffer or seeking so __setstate__ fails fast for closed StringIO instances.
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📥 CommitsReviewing files that changed from the base of the PR and between e9a57d1 and 8c5d1dd.
⛔ Files ignored due to path filters (7)📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.rs: Follow the default rustfmt code style using cargo fmt to format Rust code
Always run clippy to lint code (cargo clippy) before completing tasks and fix any warnings or lints introduced by changes
Follow Rust best practices for error handling and memory management
Use the macro system (pyclass, pymodule, pyfunction, etc.) when implementing Python functionality in Rust
Files:
crates/vm/src/builtins/tuple.rs (3)⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)crates/vm/src/builtins/int.rs (3)
- class (41-43)
- class (527-529)
- __getnewargs__ (352-362)
- __getnewargs__ (560-562)
- a (623-623)
- a (659-659)
crates/vm/src/vm/context.rs (1)crates/vm/src/stdlib/io.rs (4)138-138: LGTM!
The __getnewargs_ex__ constant is correctly added in alphabetical order after __getnewargs__, following the existing pattern for magic method names.
crates/vm/src/builtins/object.rs (7)161-162: LGTM!
The added imports for PyDict and PyTupleRef are necessary for the new __getstate__ and __setstate__ methods.
4081-4103: LGTM!
The __getstate__ implementation correctly captures StringIO state (content, newline, position, dict). The TODO at line 4096 acknowledges that actual newline handling needs future implementation.
4290-4309: LGTM!
The BytesIO.__getstate__ correctly returns a 3-tuple (content, position, dict) which matches CPython's expected state format for BytesIO.
4311-4347: LGTM!
The BytesIO.__setstate__ implementation properly validates the closed state, checks for exports via try_resizable, and correctly restores content, position, and dict.
626-644: LGTM!
The is_getstate_overridden function correctly detects if a type has overridden __getstate__ by comparing the method reference against object.__getstate__.
646-656: LGTM!
The object_getstate function correctly delegates to either the overridden __getstate__ method or the default implementation based on whether the method is overridden.
658-674: LGTM!
The get_items_iter function correctly returns iterators for list/dict items when applicable, using fast_isinstance for efficient type checks.
676-734: LGTM!
The reduce_newobj function correctly implements protocol >= 2 reduction:
- Properly checks for tp_new availability
- Correctly chooses between __newobj__ and __newobj_ex__ based on kwargs presence
- Computes the required flag correctly for state retrieval
- Returns the expected 5-tuple format
736-743: LGTM!
The common_reduce function cleanly delegates to reduce_newobj for protocol >= 2, maintaining the fallback to copyreg._reduce_ex for older protocols.
564-624: Verify identifier! macro resolution for __getnewargs_ex__.
The function uses identifier!(vm, __getnewargs_ex__) at line 571. Ensure this macro properly resolves to the newly added constant in context.rs. Unable to verify in current sandbox environment—manual verification or compilation check via cargo clippy required.
187-239: No changes needed. The weakref detection logic in object_getstate_default is correct and consistent with the codebase patterns.
Both detection mechanisms are intentional and accurate:
- Heap types without explicit __slots__ automatically support weakref—this matches CPython behavior and is confirmed by comments in type.rs (lines 1294-1295).
- For builtin types, checking attributes.contains_key() for __weakref__ is the correct method in this codebase to detect weakref support, following the same pattern used for __dict__ descriptor detection (type.rs, lines 1441-1446).
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
Sorry, something went wrong.
|
✅ Actions performed
Review triggered.
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary by CodeRabbit
New Features
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.