Skip to content

gh-157833: Fix specialized C calls with additional method flags - #157834

Merged
markshannon merged 3 commits into
python:mainfrom
overcat:fix-call-builtin-meth-flags
Sep 30, 2026
Merged

markshannon merged 3 commits into
python:mainfrom
overcat:fix-call-builtin-meth-flags

Conversation

@overcat

@overcat overcat commented Sep 20, 2026 •

Copy link
Copy Markdown

Fixes #157833

Ignore METH_CLASS, METH_STATIC and METH_COEXIST in the specialized C call guards and corresponding Tier 2 optimizer checks. This prevents calls accepted by the specializer from failing their flag guards on every call. METH_METHOD remains checked because it changes the C calling convention.

Add Tier 1 and Tier 2 regression tests for all seven affected instructions, regenerate the affected files.

@python-cla-bot

python-cla-bot Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@cocolato cocolato left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we can add a mask macro like this:

#define _Py_METH_CALL_FLAGS \
    (METH_VARARGS | METH_FASTCALL | METH_NOARGS | METH_O | METH_KEYWORDS | METH_METHOD)

Comment thread Python/bytecodes.c Outdated
Comment thread Python/optimizer_bytecodes.c Outdated
@overcat
overcat requested a review from cocolato September 20, 2026 11:09
Comment thread Lib/test/test_capi/test_opt.py Outdated
Comment thread Lib/test/test_capi/test_opt.py Outdated

@markshannon markshannon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good.
Thanks @overcat for the code, and @cocolato for the review.

@markshannon
markshannon merged commit 069c74a into python:main Sep 30, 2026
81 of 83 checks passed
@cocolato cocolato added the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Oct 1, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @overcat for the PR, and @markshannon for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Oct 1, 2026

Copy link
Copy Markdown

GH-158544 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Oct 1, 2026
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.

C call specialization misses with METH_CLASS, METH_STATIC or METH_COEXIST

3 participants