GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||
GeezerVison is showing github.com — Fix test_io on windows by youknowone · Pull Request #6387 · RustPython/RustPython Conversation
|
|
Caution Review failedThe pull request is closed. WalkthroughThis pull request adds Destructor trait implementations to six IO classes in RustPython's stdlib module, enabling proper resource cleanup when these objects are garbage collected. Each class now declares Destructor in its pyclass declaration and implements slot_del to call close(). TextIOWrapper additionally gains Iterable and IterNext implementations. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Areas requiring extra attention:
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
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 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Code has been automatically formatted The code in this PR has been formatted using git pull origin test-io |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
crates/vm/src/stdlib/io.rs (1)
1761-1771: Consider a macro for Destructor implementations (optional).There are now 7 nearly identical
Destructorimplementations. A macro could reduce duplication:macro_rules! impl_io_destructor { ($type:ty) => { impl Destructor for $type { fn slot_del(zelf: &PyObject, vm: &VirtualMachine) -> PyResult<()> { let _ = vm.call_method(zelf, "close", ()); Ok(()) } #[cold] fn del(_zelf: &Py<Self>, _vm: &VirtualMachine) -> PyResult<()> { unreachable!("slot_del is implemented") } } }; }However, this is entirely optional — the current explicit implementations are clear and maintainable.
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Lib/test/test_io.py is excluded by !Lib/**.github/workflows/ci.yaml (0 hunks)crates/vm/src/stdlib/io.rs (10 hunks)📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.rs: Follow the default rustfmt code style by runningcargo fmtto format Rust code
Always run clippy to lint Rust 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/stdlib/io.rsLearnt from: CR
Repo: RustPython/RustPython PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-29T12:17:28.606Z
Learning: Applies to **/*.rs : Use the macro system (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust
Applied to files:
crates/vm/src/stdlib/io.rscrates/vm/src/stdlib/io.rs (8)
1755-1771: LGTM!The Destructor implementation for
BufferedReadercorrectly follows the established pattern from_IOBase, properly swallowing errors fromclose()which is appropriate behavior for a destructor.
1824-1840: LGTM!Consistent Destructor implementation for
BufferedWriter.
1878-1900: LGTM!Consistent Destructor implementation for
BufferedRandom.
1944-2003: LGTM!Consistent Destructor implementation for
BufferedRWPair.
2476-2479: LGTM!The
pyclassdeclaration correctly includesDestructor,Iterable, andIterNexttraits.
3342-3391: LGTM!The
TextIOWrapperimplementations are well-designed:
- Destructor: Follows the established pattern.
- Iterable: Correctly checks if closed before returning self as iterator.
- IterNext: Properly sets
telling = falseduring iteration (matching CPython behavior), releases the lock during thereadlinecall to avoid holding it during I/O, and correctly restores state onStopIteration.
4284-4292: LGTM!The necessary imports for
Destructorand related types are correctly added.
4551-4779: LGTM!The
FileIODestructor implementation is consistent with the other I/O types and correctly ensures proper cleanup.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.