◐ Shell
clean mode source ↗

Use cfg_select in a bunch more places by coolreader18 · Pull Request #7740 · RustPython/RustPython

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 77f7958f-3e06-4c87-a695-68606e7e020a

📥 Commits

Reviewing files that changed from the base of the PR and between 79c4439 and 615583d.

📒 Files selected for processing (2)
  • crates/stdlib/src/faulthandler.rs
  • crates/stdlib/src/openssl.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/stdlib/src/openssl.rs

📝 Walkthrough

Walkthrough

This PR replaces many scattered #[cfg(...)] attribute blocks with unified cfg_select! macro expressions across the codebase, consolidating platform- and feature-gated type aliases and in-function branching without changing observable behavior.

Changes

Type alias consolidation with cfg_select!

Layer / File(s) Summary
Data Shape / Type aliases
crates/common/src/rc.rs, crates/common/src/str.rs, crates/host_env/src/crt_fd.rs, crates/vm/src/buffer.rs, crates/vm/src/codecs.rs, crates/vm/src/stdlib/_signal.rs, crates/vm/src/stdlib/_ctypes/simple.rs
Replace multiple #[cfg]-gated type/const definitions with single cfg_select! expressions for platform- or feature-dependent aliases (PyRc<T>, wchar_t, Offset, Raw, NativeEndian, UTF_*_NE, sighandler_t, SIMPLE_TYPE_CHARS).
Wiring / Usage
crates/vm/src/codecs.rs, crates/vm/src/buffer.rs, crates/vm/src/stdlib/_signal.rs
Updated code now refers to the unified aliases/constants; no semantic changes to consumers' logic.
Tests / Docs (implicit)
(none changed)
No public API signatures changed; behavior preserved at compile-time selection sites.

Conditional function/method logic refactoring

Layer / File(s) Summary
Platform/feature branching refactor
crates/common/src/refcount.rs, crates/stdlib/src/faulthandler.rs, crates/stdlib/src/openssl.rs, crates/stdlib/src/socket.rs, crates/stdlib/src/ssl.rs, crates/vm/src/exceptions.rs, crates/vm/src/getpath.rs, crates/vm/src/stdlib/_ctypes/function.rs, crates/vm/src/stdlib/_io.rs, crates/vm/src/stdlib/os.rs, crates/vm/src/stdlib/time.rs, crates/vm/src/version.rs
Replace #[cfg]-gated code paths inside functions/methods with cfg_select! expressions, consolidating platform/feature-specific control flow (signal-safe writes, OpenSSL version dispatch, endianness/encoding constants, path/stdlib selection, time conversion, error fields).
Behavioral preservation
various
All branches preserve former behavior per-target/version; selection mechanism is now macro-based rather than #[cfg] block splitting.
Tests / Validation (implicit)
(none changed)
No public signatures changed; tests not modified in this diff.

High-level runtime & VM conditionalization

Layer / File(s) Summary
VM/runtime initialization
crates/vm/src/vm/mod.rs, crates/vm/src/vm/vm_object.rs, src/interpreter.rs, src/lib.rs
Consolidate feature/platform conditional logic in VM init, exception panic handling, frozen vs dynamic stdlib setup, and run_file execution path to cfg_select!-based dispatches instead of separate #[cfg] branches.
Control flow
same files
Preserves original platform/feature behavior (main-thread checks, signal handling, wasm/no-wasm panic paths, host_env vs sandbox run_file).
Tests / Docs (implicit)
(none changed)
No API surface changes; runtime behaviors remain targeted per config.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers

  • ShaharNaveh
  • youknowone

Poem

🐰
I hopped through cfg blocks with delight,
Replaced the scattered guards with one bright light,
cfg_select! now picks the right way,
Clean compile-time choices — hip hip hooray! ✨

🚥 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 directly and accurately describes the main change: applying cfg_select macro in multiple places throughout the codebase instead of using #[cfg] conditional compilation blocks.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

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