Skip to content

host_env: export ctypes, chflags, SIG_DFL - #8766

Merged
youknowone merged 2 commits into
RustPython:mainfrom
youknowone:host-env-ctypes-stat-signal
Sep 21, 2026
Merged

youknowone merged 2 commits into
RustPython:mainfrom
youknowone:host-env-ctypes-stat-signal

Conversation

@youknowone

@youknowone youknowone commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

Move remaining stdlib numeric constants onto host_env, then publish them from the stdlib modules.

host_env now owns:

  • _ctypes FUNCFLAG_*, TYPEFLAG_*, DICTFLAG_FINAL, and CTYPES_MAX_ARGCOUNT
  • BSD chflags bits libc does not bind (UF_SETTABLE/UF_NOUNLINK/…, SF_*, macOS SF_SUPPORTED/SF_SYNTHETIC)
  • AT_FDCWD
  • SIG_DFL/SIG_IGN/SIG_ERR (libc on unix, Windows literals)

Wasm keeps local SIG_* literals because host_env::signal is unix/windows only.

Summary by CodeRabbit

  • New Features

    • Added cross-platform operating system, signal, and foreign-function interface constants.
    • Added support for signal handler constants on Windows and other non-Unix platforms.
    • Added file descriptor and file-flag constants across supported platforms.
  • Improvements

    • Standardized standard-library constants across platforms for more consistent behavior.
    • Exposed a maximum argument limit for ctypes operations.

Publish ctypes FUNCFLAG/TYPEFLAG/DICTFLAG and CTYPES_MAX_ARGCOUNT,
BSD chflags bits libc does not bind, AT_FDCWD, and SIG_DFL/IGN/ERR.

Assisted-by: Claude
_ctypes, _stat, os.AT_FDCWD, and Windows SIG_DFL/IGN/ERR now re-export
the host_env names. Wasm keeps local SIG_* literals.

Assisted-by: Claude
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Understand this PR’s impact

Explore downstream dependencies and potential security impact with Blast Radius.

View blast radius →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: RustPython/RustPython/.coderabbit.yml

Review profile: CHILL

Plan: Advanced

Run ID: 532800f5-f8a4-43d3-9a67-237a86939853

📥 Commits

Reviewing files that changed from the base of the PR and between 8fda0ec and b91bffc.

📒 Files selected for processing (7)
  • crates/host_env/src/ctypes.rs
  • crates/host_env/src/os.rs
  • crates/host_env/src/signal.rs
  • crates/vm/src/stdlib/_ctypes.rs
  • crates/vm/src/stdlib/_signal.rs
  • crates/vm/src/stdlib/_stat.rs
  • crates/vm/src/stdlib/os.rs

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The change centralizes ctypes, filesystem, and signal constants in host environment modules. Standard-library modules now import these constants and extend signal constant coverage to Windows.

Changes

Host constant integration

Layer / File(s) Summary
Host constant definitions
crates/host_env/src/ctypes.rs, crates/host_env/src/os.rs, crates/host_env/src/signal.rs
The host environment exports ctypes flags, filesystem flags, AT_FDCWD, and platform-conditional signal handler constants.
Standard-library constant wiring
crates/vm/src/stdlib/_ctypes.rs, crates/vm/src/stdlib/_stat.rs, crates/vm/src/stdlib/os.rs
The standard-library modules use host-environment definitions instead of local constant definitions.
Signal platform coverage
crates/vm/src/stdlib/_signal.rs
Signal constants are sourced from the host signal module on Unix and Windows. Fallback definitions apply only to other platforms.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Suggested reviewers: shaharnaveh

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: exporting ctypes, chflags, and SIG_DFL-related constants through host_env. It is concise and sufficiently specific despite not listing every exported cons…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 7 files.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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.

@codspeed

codspeed Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 62 untouched benchmarks
⏩ 4 skipped benchmarks1


Comparing youknowone:host-env-ctypes-stat-signal (b91bffc) with main (8fda0ec)

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 merged commit fe45a7a into RustPython:main Sep 21, 2026
31 checks passed
@youknowone
youknowone deleted the host-env-ctypes-stat-signal branch September 21, 2026 13:20
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.

1 participant