Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Magic methods in #[pymethods] don't check they have the correct number of arguments #2010

Closed
davidhewitt opened this issue Nov 20, 2021 · 0 comments · Fixed by #2083
Closed

Comments

@davidhewitt
Copy link
Member

From #1964:

By the way, I discovered that it is possible to omit arguments to the methods, e.g. to define a __richcmp__ without arguments. It seems to be handled all right, just not passing the slot arguments to Rust, but I wonder if that's intentional.

Yeah I kinda knew about this and was thinking it was a minor bug. It probably should be checked and a nice error message emitted. Users missing arguments off is probably an incorrect implementation imo so we should at least force them to be explicit about unused arguments.

The code responsible is:

fn extract_proto_arguments(

method_args are the arguments the user wrote for the method; at the moment the code just iterates it without checking its length. Slightly complicated by the Python arguments but not too bad.


Anyone who's interested in helping out with this, it should be a reasonably self-contained piece.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant