Skip to content

Commit

Permalink
also support __richcmp__
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt committed Nov 8, 2024
1 parent 8086763 commit 6f15625
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pyo3-macros-backend/src/pymethod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1348,13 +1348,19 @@ impl SlotDef {
)?;
let name = spec.name;
let holders = holders.init_holders(ctx);
let dep = if method_name == "__richcmp__" {
quote! { impl #pyo3_path::impl_::pyclass::HasCustomRichCmp for #cls {} }
} else {
TokenStream::default()
};
let associated_method = quote! {
#[allow(non_snake_case)]
unsafe fn #wrapper_ident(
py: #pyo3_path::Python<'_>,
_raw_slf: *mut #pyo3_path::ffi::PyObject,
#(#arg_idents: #arg_types),*
) -> #pyo3_path::PyResult<#ret_ty> {
#dep
let function = #cls::#name; // Shadow the method name to avoid #3017
let _slf = _raw_slf;
#holders
Expand Down

0 comments on commit 6f15625

Please sign in to comment.