Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

macros: clean up protocol argument extraction a bit #1958



Copy link

This PR just tidies up the code which does argument extraction for protocol #[pymethods] a little.

Comment on lines 456 to 459
const __IADD__: SlotDef = SlotDef::new("Py_nb_inplace_add", "binaryfunc")
Copy link
Member Author

Choose a reason for hiding this comment

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

@birkenfeld: in answer to #1945 (comment)

These definitions state what the generated function signature will be and place constraints on what is allowed in the pymethod. For example this __iadd__ definition will require there to be only one argument, of any type, and the return type to be () or PyResult<()> (because the macro-generated code will return self).

If the user deviates from these constraints there should be a compile error, however the error messages can probably be improved.

@davidhewitt davidhewitt force-pushed the pymethods-protos-arguments-cleanup branch from a4cb2ff to 6a3e1e7 Compare October 31, 2021 11:30
@davidhewitt davidhewitt merged commit 0f92f28 into PyO3:main Oct 31, 2021
@davidhewitt davidhewitt deleted the pymethods-protos-arguments-cleanup branch October 31, 2021 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

1 participant