Skip to content

Commit

Permalink
fix: updated pyclass heighten check to validate for eq and ord, fixin…
Browse files Browse the repository at this point in the history
…g Ok issue in eq implementation.
  • Loading branch information
MG committed Jul 17, 2024
1 parent ba234b2 commit a37c24b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyo3-macros-backend/src/pyclass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1915,7 +1915,7 @@ fn pyclass_richcmp(
op: #pyo3_path::pyclass::CompareOp
) -> #pyo3_path::PyResult<#pyo3_path::PyObject> {
let self_val = self;
if let Ok(other) = #pyo3_path::types::PyAnyMethods::downcast::<Self>(other) {
if let ::std::result::Result::Ok(other) = #pyo3_path::types::PyAnyMethods::downcast::<Self>(other) {
let other = &*other.borrow();
match op {
#arms
Expand Down
9 changes: 9 additions & 0 deletions src/tests/hygiene/pyclass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ pub struct Foo4 {
field: u32,
}

#[crate::pyclass(eq, ord)]
#[pyo3(crate = "crate")]
#[derive(PartialEq, PartialOrd)]
pub struct PointEqOrd {
x: u32,
y: u32,
z: u32,
}

#[crate::pyclass(str = "{x}, {y}, {z}")]
#[pyo3(crate = "crate")]
pub struct PointFmt {
Expand Down

0 comments on commit a37c24b

Please sign in to comment.