align overlapped to CPython 3.14.2 by youknowone · Pull Request #7005 · RustPython/RustPython
📝 Walkthrough
Walkthrough
This change refactors the Windows overlapped I/O module by introducing module initialization with Winsock setup, adding garbage collection traversal support through Traverse implementations, updating function signatures for stricter type safety, centralizing error handling via a new helper, and caching operation results in data structures.
Changes
| Cohort / File(s) | Summary |
|---|---|
Module Initialization & GC Support crates/stdlib/src/overlapped.rs |
Added module_exec function for Winsock initialization and updated #[pyclass] with traverse support; extended imports for PyModule, PyStrRef, PyTupleRef, and Traverse trait implementations for OverlappedInner, OverlappedReadFrom, and OverlappedReadFromInto. |
API Signature Changes crates/stdlib/src/overlapped.rs |
Updated WSAConnect, parse_address to accept PyTupleRef instead of PyObjectRef; changed unparse_address return type from bare PyObjectRef to PyResult for explicit error handling; replaced from_windows_err helper with set_from_windows_err for uniform Windows error translation. |
Data Structure Enhancements crates/stdlib/src/overlapped.rs |
Added result: Option<PyObjectRef> field to OverlappedReadFrom and OverlappedReadFromInto to cache operation results; updated Debug formatting to display result field; modified initialization code to set result: None. |
Address Parsing & Error Handling crates/stdlib/src/overlapped.rs |
Enhanced IPv4/IPv6 address parsing to handle port restoration and return address bytes with updated length; refactored address unparsing to use std::net types (Ipv4Addr, Ipv6Addr); added buffer size checks and contiguity validation; consolidated error paths through set_from_windows_err. |
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
- Fix _overlapped segfault and missing _winapi constants #6907: Modifies the same overlapped.rs file with overlapping changes to Windows error translation patterns and Overlapped class behavior, likely representing related iterations on Winsock integration.
Poem
🐰 In Windows lands where sockets dance,
We hop through overlapping chance,
With traversal spring and errors caught,
Fresh signatures and results sought!
Winsock hops with module grace—
GC cleanup finds its place! ✨
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | Docstring coverage is 76.19% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title 'align overlapped to CPython 3.14.2' is clear and specific, directly describing the PR's main objective of aligning the _overlapped module implementation with CPython 3.14.2 compatibility standards. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing touches
- 📝 Generate docstrings
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
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 @coderabbitai help to get the list of available commands and usage tips.