Skip to content

[mypyc] Fix name conflict when creating CPyFunction variable - #21992

Merged
JukkaL merged 2 commits into
python:masterfrom
p-sawicki:cpyfunction-variable-name-conflict
Sep 15, 2026
Merged

JukkaL merged 2 commits into
python:masterfrom
p-sawicki:cpyfunction-variable-name-conflict

Conversation

@p-sawicki

@p-sawicki p-sawicki commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

Local variables for CPyFunction objects are named by taking the C name of the wrapped function and adding _wrapper at the end. This creates a name conflict when a class has two async methods with names X and X_wrapper and means that the CPyFunction variable shadows the function definition.

The function name is used as a function pointer and passing the CPyFunction object instead causes a segfault.

Fix by naming the variables by using a prefix instead. The C function names are already prefixed by CPyPy_ and the class name so there shouldn't be conflicts through Python names.

@JukkaL
JukkaL merged commit cd67720 into python:master Sep 15, 2026
18 checks passed
@p-sawicki
p-sawicki deleted the cpyfunction-variable-name-conflict branch September 16, 2026 17:44
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