GeezerVison is showing github.com — Share ctypes aggregate parameter conversion by youknowdot · Pull Request #9657 · RustPython/RustPython
Conversation
youknowdot
commented
Nov 3, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
- Share aggregate
from_param conversion across array, structure, union, and pointer fallback paths, removing duplicated parsing and adaptation logic.
- Propagate
_as_parameter_ lookup errors and use the existing recursion guard. Recursive adaptation stays in the generic converter rather than restarting pointer-only adaptations.
- Match array/byref prototype checks and use initialized pointer metadata instead of mutable
_type_ attributes. Snapshot metadata before callback-capable type checks.
No simple.rs, function.rs, tests, snippets, or workflows are changed. This composes with the separate scalar conversion work in #9654.
Validation
- Focused VM library cargo check and strict threading Clippy passed on the final source.
- Isolated CPython 3.15.0 reference probes cover lookup errors, cycles, direct versus wrapped pointer inputs, array/byref compatibility, mutated
_type_, and incomplete pointers.
- Independent source review, rustfmt, diff checks, and normal commit hooks passed.
- RustPython runtime tests, full workspace tests, C-API tests, and non-Linux execution were not run locally because the native execution guard is unavailable. Hosted CI is still required.
Aggregate CArg inputs with no initialized prototype take a safe TypeError path. This intentionally does not reproduce CPython's NULL-prototype crash.
Reference: CPython 3.15 ctypes conversion.
AI assistance
OpenAI Codex assisted with source analysis, implementation, reference-case preparation, review, and this description. Model version was not exposed by this runtime.
Summary by CodeRabbit
- Bug Fixes
- CTypes arrays, structures, and unions now use consistent parameter conversion, including support for matching instances and values exposed through
_as_parameter_.
- Pointer parameters continue to accept
None and compatible pointer or array instances; values without an initialized pointer prototype now raise a TypeError.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
chatgpt-codex-connector[bot] reacted with thumbs up emoji
Reuse generic from_param adaptation, preserve lookup errors and recursion bounds, and follow initialized prototype metadata for pointer and byref inputs.
Assisted-by: OpenAI Codex:model version not exposed
coderabbitai
Bot
commented
Nov 3, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review.
Walkthrough
-
ctypes parameter conversion is centralized in PyCData::from_param. Array, structure, and union converters delegate to it. The pointer converter retains prototype-specific handling and delegates other values to the shared converter.
Changes: ctypes Parameter Conversion
| Layer / File(s) |
Summary |
Shared parameter conversion crates/vm/src/stdlib/_ctypes/base.rs |
PyCData::from_param handles matching instances, compatible CArgObject values, recursive _as_parameter_ conversion with recursion tracking, and type errors. |
Converter integration crates/vm/src/stdlib/_ctypes/array.rs, crates/vm/src/stdlib/_ctypes/structure.rs, crates/vm/src/stdlib/_ctypes/union.rs, crates/vm/src/stdlib/_ctypes/pointer.rs |
Array, structure, and union converters delegate conversion to PyCData::from_param. The pointer converter uses initialized prototype metadata, retains its None, by-reference, and compatible pointer or array handling, and delegates other values. |
Estimated code review effort: 2 (Simple) | ~15 minutes
Change: Refactor
Possibly related PRs
- RustPython/RustPython#9685: Invokes and caches
argtypes converters during foreign-call argument conversion, which uses the ctypes argument-conversion contract.
Suggested reviewers: youknowone
Merge Risk: Minimal · up to 93bac
-
The shared ctypes conversion has no established merge-blocking issue. Merge after normal checks pass.
Pre-merge checks: 4 · 1
-
Failed checks: 1 warning
| Check name |
Status |
Explanation |
Resolution |
| Docstring Coverage |
 |
Docstring coverage is 0.00% 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. Documentat… |
Write docstrings for the functions missing them to satisfy the coverage threshold. |
Passed checks: 4 passed
-
| Check name |
Status |
Explanation |
| Description Check |
 |
Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check |
 |
The title "Share ctypes aggregate parameter conversion" matches the main change. The PR moves from_param conversion for arrays, structures, unions, and the pointer fallback path into a shared PyCData:… |
| Linked Issues check |
 |
Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check |
 |
Check skipped because no linked issues were found for this pull request. |
Full details: Title check
-
Explanation
The title "Share ctypes aggregate parameter conversion" matches the main change. The PR moves from_param conversion for arrays, structures, unions, and the pointer fallback path into a shared PyCData::from_param in base.rs, and removes the duplicated per-type logic. The title names the subject (ctypes aggregate parameter conversion) and the action (sharing it), and it is consistent with the PR objectives. It does not cover details such as the recursion guard, metadata snapshotting, or the TypeError path for prototype-less CArg inputs, which is acceptable for a title.
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 0.00% 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 2 functions across 5 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Finishing Touches
-
Generate unit tests (beta)
-
- 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
-
Recent review info
-
Run configuration
-
Commits
-
Reviewing files that changed from the base of the PR and between 7e1c3e9 and 93bac84.
Files selected for processing: 5
-
crates/vm/src/stdlib/_ctypes/array.rs
crates/vm/src/stdlib/_ctypes/base.rs
crates/vm/src/stdlib/_ctypes/pointer.rs
crates/vm/src/stdlib/_ctypes/structure.rs
crates/vm/src/stdlib/_ctypes/union.rs
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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-04T12:44:39.885005Z |
93bac84 |
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.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Nov 4, 2026
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|