◐ Shell
clean mode source ↗

fix fcntl, sslsocket traverse, super , excepthook by youknowone · Pull Request #6623 · RustPython/RustPython

📝 Walkthrough

Walkthrough

The changes span multiple subsystems: ioctl's parameter type widening from u32 to i64 with runtime bit-pattern casting, SSL socket garbage collection optimization through traversal markers, super() function's type argument validation enhancement, new thread exception hook infrastructure with a dedicated argument class, and warning context setup flow adjustments for frame availability handling.

Changes

Cohort / File(s) Summary
I/O Control Parameter Handling
crates/stdlib/src/fcntl.rs
Modified ioctl() to accept request as i64 instead of u32, with runtime reinterpretation via cast to u32 then zero-extended to libc::c_ulong to handle negative bit-pattern values.
SSL Socket Garbage Collection
crates/stdlib/src/ssl.rs
Enabled traverse on PySSLSocket pyclass and marked 10 fields (server_side, server_hostname, connection, handshake_done, session_was_reused, verified_chain, sni_state, client_hello_buffer, shutdown_state, deferred_cert_error) with pytraverse(skip) to exclude them from Python-side GC traversals.
Super Type Validation
crates/vm/src/builtins/super.rs
Changed InitArgs.py_type field from OptionalArg<PyTypeRef> to OptionalArg<PyObjectRef> and added runtime downcast with type validation; raises error if first argument is not a type.
Thread Exception Hook Infrastructure
crates/vm/src/stdlib/thread.rs
Added ExceptHookArgs pyclass (_ExceptHookArgs) with four fields (exc_type, exc_value, exc_traceback, thread) and accessor properties; added _excepthook() pyfunction to handle exception hook invocation with traceback printing to appropriate stderr target.
Warning Context Setup
crates/vm/src/warn.rs
Updated setup_context() control flow: when a frame exists but wasn't stack-discovered, use its globals with filename "<sys>" and lineno 1; added fallback path for no-frame case using sys.__dict__ as globals with lineno 0, replacing prior single fallback using vm.current_globals().

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~35 minutes

Possibly related PRs

Suggested reviewers

  • ShaharNaveh
  • arihant2math

Poem

🐰 Hops with glee through RustPython's halls,
Casting types and marking traversals!
SSL sockets skip through GC's delight,
While super() validates with all its might.
Thread exceptions and warnings align—
A patchwork of fixes, how sublime!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The title directly references the four main changes: fcntl fixes, sslsocket traverse fixes, super fixes, and excepthook additions—accurately capturing the pull request's scope.
✨ Finishing touches
  • 📝 Generate docstrings

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.