GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-125788: Improve ctypes error message for mismatched callback prototypes by aribaskagan · Pull Request #161873 · python/cpython

Conversation

@aribaskagan

@aribaskagan aribaskagan commented Nov 12, 2026 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

When a CFUNCTYPE/WINFUNCTYPE callback is passed where a different callback prototype is expected, ctypes raised a confusing error because both prototype classes share the name CFunctionType:

ctypes.ArgumentError: argument 4: TypeError: expected CFunctionType instance instead of CFunctionType

This change makes CDataType_from_param_impl() report the expected and actual signatures when both sides are callback prototypes with argtypes set:

ctypes.ArgumentError: argument 4: TypeError: expected CFunctionType instance with signature (restype=<class 'ctypes.c_int'>, argtypes=(<class 'ctypes.c_void_p'>, <class 'ctypes.c_void_p'>)) instead of CFunctionType instance with signature (restype=<class 'ctypes.c_long'>, argtypes=(<class 'ctypes.c_void_p'>, <class 'ctypes.c_void_p'>))

Call behavior is unchanged; other mismatches keep the existing wording. Added test_mismatched_callback_prototype based on the qsort reproducer from the issue, plus a NEWS entry. ./python -m test test_ctypes passes on a Linux debug build.

AI assistance was used in preparing this change; I reviewed and tested it.

  • Issue: Ctypes: Unclear Error Message for WinFunctionType Mismatch in Windows API Calls #125788

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
All reactions
  • 👍 1 reaction
@aribaskagan
pythongh-125788: Improve ctypes error message for mismatched callback…
fd17c9a
… 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ş <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 12, 2026 14:20
@python-cla-bot

python-cla-bot Bot commented Nov 12, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

The following commit authors need to sign the Contributor License Agreement:

  • [email protected]

CLA not signed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added the type-feature A feature request or enhancement label Nov 12, 2026
@bedevere-app bedevere-app Bot mentioned this pull request Nov 12, 2026
Ctypes: Unclear Error Message for WinFunctionType Mismatch in Windows API Calls #125788
Open
Copilot AI reviewed Nov 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T14:24:58.355484Z f6c92af PR opened
ℹ️ 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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot added the awaiting review label Nov 12, 2026
@cursor
cursor Bot force-pushed the gh-125788-ctypes-callback-error branch from f6c92af to fd17c9a Compare November 12, 2026 17:02
@ZeroIntensity ZeroIntensity added the AI-needs-explanation AI-assisted work that needs further explanation and follow up from the contributor label Nov 12, 2026
@bedevere-app

bedevere-app Bot commented Nov 12, 2026

Copy link
Copy Markdown

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

AI-needs-explanation AI-assisted work that needs further explanation and follow up from the contributor awaiting review type-feature A feature request or enhancement

Projects

None yet

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.

3 participants

@aribaskagan @ZeroIntensity
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.