GeezerVison is showing github.com — reject SemLock reduce by youknowone · Pull Request #6738 · RustPython/RustPython
Conversation
youknowone
commented
Jan 15, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary by CodeRabbit
- Bug Fixes
- Fixed pickling behavior for SemLock objects. Attempting to serialize a SemLock instance directly now properly raises an error. Users must utilize the
multiprocessing.SemLock wrapper to enable serialization support for these objects.
✏️ Tip: You can customize this high-level summary in your review settings.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Jan 15, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
📝 Walkthrough
Walkthrough
A new __reduce__ method is added to the SemLock class in the multiprocessing module. This method raises a TypeError to prevent direct pickling of SemLock objects, requiring users to use the appropriate multiprocessing.SemLock wrapper for serialization support instead.
Changes
| Cohort / File(s) |
Summary |
SemLock pickling restriction crates/stdlib/src/multiprocessing.rs |
Added __reduce__ method to SemLock class that raises TypeError with message "cannot pickle 'SemLock' object" to block direct serialization |
Estimated code review effort
🎯 1 (Trivial) | ⏱️ ~2 minutes
Possibly related PRs
- RustPython/RustPython#6542: Modifies the core
SemLock implementation in multiprocessing module; this PR complements it by adding pickle prevention via the __reduce__ method.
Poem
🐰 A lock that cannot be pickled sweet,
No brines nor jars shall make it neat,
For SemLock stays locked away,
Wrap it well, the proper way! 🔒
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
| Check name |
Status |
Explanation |
| Description Check |
✅ Passed |
Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check |
✅ Passed |
The title 'reject SemLock reduce' directly and specifically describes the main change: preventing SemLock objects from being pickled by implementing a reduce method that rejects serialization. |
| Docstring Coverage |
✅ Passed |
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
✏️ 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
📥 Commits
Reviewing files that changed from the base of the PR and between 609dbb1 and 5697ab3.
⛔ Files ignored due to path filters (1)
Lib/test/test_concurrent_futures/test_process_pool.py is excluded by !Lib/**
📒 Files selected for processing (1)
crates/stdlib/src/multiprocessing.rs
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 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/stdlib/src/multiprocessing.rs
🔇 Additional comments (1)
crates/stdlib/src/multiprocessing.rs (1)
550-555: LGTM!
The __reduce__ method correctly prevents direct pickling of SemLock objects by raising a TypeError. This is consistent with CPython's behavior and the existing _rebuild classmethod design pattern—the higher-level multiprocessing.synchronize.SemLock wrapper is expected to handle serialization while using _rebuild for reconstruction.
✏️ 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.
❤️ 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.
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.