Skip to content

Add PyABIInfo_Check to the c-api - #8941

Merged
youknowone merged 1 commit into
RustPython:mainfrom
bschoenmaeckers:c-api-abi-check
Oct 2, 2026
Merged

youknowone merged 1 commit into
RustPython:mainfrom
bschoenmaeckers:c-api-abi-check

Conversation

@bschoenmaeckers

@bschoenmaeckers bschoenmaeckers commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes
    • Improved compatibility checks for native modules using the stable and free-threaded ABIs. Unsupported ABI versions or missing required ABI support now produce an import error with the affected module identified when available.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@coderabbitai

coderabbitai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
AGENTS.md — auto-discovered

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: 684b09cb-9b73-4924-ab7b-85da4215ff79

📥 Commits

Reviewing files that changed from the base of the PR and between c8d63e8 and 1389d89.

📒 Files selected for processing (2)
  • crates/capi/src/modsupport.rs
  • crates/capi/src/slots.rs

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


📝 Walkthrough

Walkthrough

The change moves PyABIInfo to modsupport, adds ABI support validation, and exposes that validation through PyABIInfo_Check. The check accepts ABI major version 0 and validates version 1 flags.

Changes

PyABIInfo validation

Layer / File(s) Summary
Define and expose PyABIInfo validation
crates/capi/src/modsupport.rs, crates/capi/src/slots.rs
modsupport.rs defines PyABIInfo and checks ABI major versions and flags. It adds PyABIInfo_Check, which converts the optional module name and returns the validation result through the C API. slots.rs imports the shared type and removes its local definition and check.

Priority: ⬇️ Low

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

Merge Risk: ⚪ Minimal · up to 1389d

No actionable compatibility issue was established; the change is ready for normal merge checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 1389d

The new check reads native caller-provided metadata and follows existing interpreter error handling, without a demonstrated increase in authority. Its external compatibility requirements and caller obligations are not fully verified, so the remaining risk is low rather than minimal.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated exposure is an in-process native C API within an attached interpreter. The inspected path does not establish a Python-level attacker entrypoint or expanded privilege; external native callers and their exposure remain unknown.

Trust Boundaries and Controls

  • observed — The checker relies on native caller obligations: the descriptor must remain valid and immutable during its borrow, and a non-null module name must reference a valid C string. VM attachment is required by the existing helper. The function does not acquire capabilities, transfer ownership or attach a VM itself.

Resilience and Maintainability Implications

  • observed — Failures replace the current interpreter exception and return -1; success returns 0 without clearing an existing exception. Repeated calls therefore inherit the established C API error-state behavior. The check creates no reservation, retained resource or ownership transition requiring rollback or cleanup.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 identifies the main change: adding PyABIInfo_Check to the C API.
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

@youknowone
youknowone enabled auto-merge (squash) October 2, 2026 09:24
@youknowone
youknowone merged commit ada43c4 into RustPython:main Oct 2, 2026
20 checks passed
@bschoenmaeckers
bschoenmaeckers deleted the c-api-abi-check branch October 2, 2026 11:14
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.

2 participants