◐ Shell
clean mode source ↗

impl {raise_,str}signal by youknowone · Pull Request #6411 · RustPython/RustPython

Walkthrough

The PR extends the signal handling module with three new cross-platform utility functions (raise_signal, strsignal, valid_signals) featuring platform-specific implementations, modifies set_wakeup_fd to return i64 with Windows validation, and adds year validation for time formatting on Windows.

Changes

Cohort / File(s) Summary
Signal handling API expansion
crates/vm/src/stdlib/signal.rs
Changed set_wakeup_fd return type from PyResult<WakeupFdRaw> to PyResult<i64> with platform-specific handling and Windows runtime validation. Added three new public functions: raise_signal (validates and raises signals with platform restrictions), strsignal (returns signal name via libc on Unix, custom mapping on Windows), and valid_signals (returns PySet of valid signal numbers with platform-specific contents).
Time formatting validation
crates/vm/src/stdlib/time.rs
Added runtime guard in strftime to enforce year >= 1900 when using %y format on Windows, AIX, or Solaris, returning ValueError if violated.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • signal.rs: New public API surface with three functions requiring careful review of platform-specific implementations (Unix vs. Windows variants), return type change implications for set_wakeup_fd, and validation logic differences.
  • time.rs: Simple validation guard with clear intent.
  • Areas needing attention:
    • Platform-specific behavior correctness in raise_signal, strsignal, and valid_signals
    • Impact of set_wakeup_fd return type change on callers and type safety
    • Windows fd validation logic in set_wakeup_fd
    • Completeness of signal mappings in Windows strsignal implementation

Suggested reviewers

  • ShaharNaveh

Poem

🐰 Signals now sing with cross-platform cheer,
Valid signals listed, crystal clear,
Wakeup file descriptors dance to i64,
Time guards the year—what could we ask for more?
—Rabbit the Reviewer, hopping through the code 🎉

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.
Title check ✅ Passed The title 'impl {raise_,str}signal' accurately reflects the main changes, which introduce three new signal-handling functions: raise_signal, strsignal, and valid_signals.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.