Repository navigation
gh-125788: Improve ctypes error message for mismatched callback prototypes - #161873
aribaskagan wants to merge 1 commit into
Conversation
… prototypes CFUNCTYPE and WINFUNCTYPE prototypes are distinct classes that share one type name, so a mismatch was reported as "expected CFunctionType instance instead of CFunctionType". Include both signatures in the TypeError. Co-authored-by: Kağan Arıbaş <aribaskagan@gmail.com>
|
The following commit authors need to sign the Contributor License Agreement: |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
f6c92af to
fd17c9a
Compare
|
Thank you for your interest in contributing to Python. This is a community-driven project, and we want it to be a welcoming place to learn and collaborate. Contributors are responsible for reviewing and understanding what they submit, checking its claims, and being able to explain changes in their own words. This helps reviewers focus on the contribution and leaves more time to support other contributors. This contribution appears to have been authored with AI assistance. Please explain your contribution in your own words and describe how you checked its correctness. Please read our guidelines for using AI tools. |
When a
CFUNCTYPE/WINFUNCTYPEcallback is passed where a different callback prototype is expected, ctypes raised a confusing error because both prototype classes share the nameCFunctionType:This change makes
CDataType_from_param_impl()report the expected and actual signatures when both sides are callback prototypes withargtypesset:Call behavior is unchanged; other mismatches keep the existing wording. Added
test_mismatched_callback_prototypebased on the qsort reproducer from the issue, plus a NEWS entry../python -m test test_ctypespasses on a Linux debug build.AI assistance was used in preparing this change; I reviewed and tested it.