Skip to content

Commit

Permalink
Remove usage of AsPyPointer in traits for convergint to PyObject
Browse files Browse the repository at this point in the history
Refs #3358
  • Loading branch information
alex committed Aug 16, 2023
1 parent 82b1e55 commit df5b5bf
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -933,12 +933,18 @@ impl<T> crate::AsPyPointer for Py<T> {
}
}

impl std::convert::From<&'_ PyAny> for PyObject {
fn from(obj: &PyAny) -> Self {
unsafe { Py::from_borrowed_ptr(obj.py(), obj.as_ptr()) }
}
}

impl<T> std::convert::From<&'_ T> for PyObject
where
T: AsPyPointer + PyNativeType,
T: PyNativeType + AsRef<PyAny>,
{
fn from(obj: &T) -> Self {
unsafe { Py::from_borrowed_ptr(obj.py(), obj.as_ptr()) }
unsafe { Py::from_borrowed_ptr(obj.py(), obj.as_ref().as_ptr()) }
}
}

Expand Down

0 comments on commit df5b5bf

Please sign in to comment.