Skip to content

Align OS callable signatures and argument conversions - #9536

Merged
youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:fix/os-signature-bindings-20261102
Nov 2, 2026
Merged

youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:fix/os-signature-bindings-20261102

Conversation

@youknowdot

@youknowdot youknowdot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Address twelve concrete whats_left signature mismatches from #9530's Ubuntu report (head 68646843423633e60bd54c6d4150db953b303804, CPython 3.15.0), with corresponding argument declarations rather than arbitrary signature strings:

  • Correct defaults/names for get_child_pids, mmap.flush, epoll poll/__exit__, socket send/sendall, pidfd_send_signal, scheduler setters, getrandom, pidfd_open, and copy_file_range.
  • Accept the keywords CPython actually accepts for getrandom, pidfd_open, and copy_file_range.
  • Fix adjacent real converter defects: preserve explicit recursive=None until boolean conversion after pid conversion; reject mmap.flush(..., None) through its integer converter; use signed C-int flags for getrandom/pidfd_send_signal; allow raw C-int signal numbers, including zero, for pidfd_send_signal without weakening other APIs' SignalNum invariant.
  • Add the already-reviewed --signature flag to the existing CI comparison so the exact after-head report can measure the proposed reductions. It only prints results already computed; no extra scan/import/run is introduced.

Source contracts

CPython reference: d220409a / Python 3.15.0.

  • Modules/clinic/posixmodule.c.h: keyword acceptance and signed getrandom versus unsigned pidfd_open flags.
  • Modules/_remote_debugging/clinic/module.c.h: pid conversion before PyObject_IsTrue(recursive); omitted recursive defaults to true.
  • Modules/clinic/mmapmodule.c.h: size is an integer with default -1, not a nullable size.
  • Modules/clinic/signalmodule.c.h: raw C-int signal number/flags and raw optional siginfo.

No FD ownership, host helper, or unsafe block is rewritten. Socket buffer conversion/borrow sequencing and signal siginfo validation remain scoped to their existing paths.

Validation and limits

Independent source review, normal hooks, and git diff --check passed. Local compile/unit/interpreter tests were not run because the dependency-cache/network bootstrap blocker remains. Existing CI and the exact-head signature report must validate this Draft; twelve removals are an expectation, not a measured result yet.

This does not claim full CPython syscall or error-priority compatibility. Existing copy_file_range raw-FD conversion and count/offset error-order differences, getrandom negative-size errno/EINTR behavior, and remaining epoll/sched_param report items are outside this patch. No custom signal/FD probes, assertions, Lib edits, or snippet additions are included.

Summary by CodeRabbit

  • Bug Fixes
    • Corrected default handling for optional arguments in process, polling, file-copying, and system-call interfaces.
    • Updated memory-map flushing so an omitted size flushes the remaining mapping, while invalid negative sizes are rejected.
    • Clarified socket send and send-all argument handling: data and flags must be supplied positionally.
    • Improved signal-sending argument handling and made scheduler parameter names explicit.

Match actual defaults, names and keyword acceptance for the reported OS callables. Preserve explicit recursive None until delayed truth conversion, use the integer mmap size default, and match signed C-int syscall arguments. Keep ownership and host operations unchanged. Enable existing detailed CI signature output for head-bound comparison; local native execution remains unverified.

Assisted-by: OpenAI Codex:model version not exposed
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between ef023bc and 42b5143.

Files selected for processing: 8
  • .github/workflows/ci.yaml
  • crates/stdlib/src/_remote_debugging.rs
  • crates/stdlib/src/mmap.rs
  • crates/stdlib/src/select.rs
  • crates/stdlib/src/socket.rs
  • crates/vm/src/stdlib/_signal.rs
  • crates/vm/src/stdlib/os.rs
  • crates/vm/src/stdlib/posix.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

Walkthrough

The patch updates Python argument declarations and defaults for several standard-library APIs. It changes mmap size handling and signal flag conversion. The CI whats_left.py command now includes --signature.

Changes: Standard-library argument contracts

Layer / File(s) Summary
Standard-library argument handling
crates/stdlib/src/_remote_debugging.rs, crates/stdlib/src/mmap.rs, crates/stdlib/src/select.rs, crates/stdlib/src/socket.rs
get_child_pids declares a True default for recursive. FlushOptions.size defaults to -1, which represents the remaining mapping length; other negative sizes are rejected. Epoll argument declarations use explicit defaults and an argument structure. Socket send and sendall bind positional data and defaulted positional flags through SendArgs.
VM standard-library argument handling
crates/vm/src/stdlib/_signal.rs, crates/vm/src/stdlib/os.rs, crates/vm/src/stdlib/posix.rs
pidfd_send_signal, pidfd_open, and getrandom use argument structures with defaulted flags. pidfd_send_signal passes the raw signal number and casts flags to u32. copy_file_range updates argument kinds and offset defaults. The scheduler functions explicitly name param.
CI signature check
.github/workflows/ci.yaml
The whats_left.py invocation adds --signature.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Possibly related issues

  • RustPython/RustPython issue 6839 — The issue describes standard-library alignment with CPython 3.15, and this change updates argument contracts for several standard-library APIs.

Suggested reviewers: shaharnaveh, joshuamegnauth54

Merge Risk: Minimal · up to 42b51

No actionable merge-blocking issue is established for these signature and argument-conversion updates. Merge after normal CI checks pass.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main changes: aligning OS callable signatures and argument conversions.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 6 functions across 7 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@codspeed

codspeed Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 62 untouched benchmarks
⏩ 4 skipped benchmarks1


Comparing youknowdot:fix/os-signature-bindings-20261102 (42b5143) with main (ef023bc)

Open in CodSpeed

Footnotes

  1. 4 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@youknowone
youknowone marked this pull request as ready for review November 2, 2026 15:26
@youknowone
youknowone enabled auto-merge (squash) November 2, 2026 15:26
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T15:30:14.216577Z 42b5143 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants