Add more error functions to the c-api#8248
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (18)
💤 Files with no reviewable changes (1)
✅ Files skipped from review due to trivial changes (13)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe C-API exception layer adds VM-backed exception state operations, errno and Windows error conversion helpers, Unicode error accessors, pointer-returning FFI error handling, and unrelated Rust syntax and formatting simplifications. ChangesException and error C-API
Rust cleanup
Estimated code review effort: 4 (Complex) | ~75 minutes Sequence Diagram(s)sequenceDiagram
participant C_API
participant VM
participant OS_Error
participant Exception_Type
C_API->>VM: invoke exception or OS-error helper
VM->>OS_Error: read errno or Windows last-error data
OS_Error-->>VM: error code and message
VM->>Exception_Type: construct exception with optional filenames
Exception_Type-->>C_API: return exception object
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
crates/capi/src/pyerrors/errno.rs (1)
18-56: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReduce duplication by delegating to the object-based helper.
PyErr_SetFromErrnoWithFilenamere-implements the errno read,EINTRhandling, message construction, downcast, and call logic that already exists inPyErr_SetFromErrnoWithFilenameObjects. As in CPython, this can decode the filename and then delegate toPyErr_SetFromErrnoWithFilenameObject, keeping the errno/message logic in one place.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/capi/src/pyerrors/errno.rs` around lines 18 - 56, Refactor PyErr_SetFromErrnoWithFilename to only decode the optional C filename, convert it to a Python object, and delegate to PyErr_SetFromErrnoWithFilenameObject. Remove its duplicated errno retrieval, EINTR handling, message construction, exception downcast, and call logic so the object-based helper remains the single implementation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/capi/src/pyerrors/windows.rs`:
- Around line 69-84: In the Windows error conversion branch, avoid leaking the
decoded filename created by decode_fsdefault_and_size. Update the
Some(Ok(filename)) handling to keep the PyObjectRef alive locally and pass its
borrowed raw pointer to set_windows_error, rather than calling into_raw();
preserve the existing error and None handling.
---
Nitpick comments:
In `@crates/capi/src/pyerrors/errno.rs`:
- Around line 18-56: Refactor PyErr_SetFromErrnoWithFilename to only decode the
optional C filename, convert it to a Python object, and delegate to
PyErr_SetFromErrnoWithFilenameObject. Remove its duplicated errno retrieval,
EINTR handling, message construction, exception downcast, and call logic so the
object-based helper remains the single implementation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 05c2152b-5010-4ab6-a5ca-c0afe9842760
📒 Files selected for processing (5)
crates/capi/src/pyerrors.rscrates/capi/src/pyerrors/errno.rscrates/capi/src/pyerrors/unicode.rscrates/capi/src/pyerrors/windows.rscrates/capi/src/util.rs
Summary by CodeRabbit