Skip to content

[mypyc] Fix function wrapper descriptor for static/class methods - #21811

Open
p-sawicki wants to merge 3 commits into
python:masterfrom
p-sawicki:async-classmethod-incorrect-classarg-binding
Open

[mypyc] Fix function wrapper descriptor for static/class methods#21811
p-sawicki wants to merge 3 commits into
python:masterfrom
p-sawicki:async-classmethod-incorrect-classarg-binding

Conversation

@p-sawicki

Copy link
Copy Markdown
Collaborator

Calling an async class method in interpreted context might fail on incorrect number of arguments because the class T on the lhs of the member expression T.f(a,b,c) is not bound to the cls argument. Instead the first regular argument is taken as cls and all other are shifted.

Expand the tp_descr_get slot of the function wrapper type object to correctly handle class methods.

Also modify the function lowering logic to take the method from the type dictionary instead of through getattr when calling a decorator on the method. getattr goes through the descriptor and binds the cls argument but the argument should be unbound when applying the decorator to match interpreted Python.

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.

1 participant