Skip to content

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

Open
p-sawicki wants to merge 2 commits into
python:masterfrom
p-sawicki:cpyfunction-variable-name-conflict
Open

p-sawicki wants to merge 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.

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