Remove usage of `AsPyPointer` in traits for convergint to PyObject
Refs #3358
This commit is contained in:
parent
82b1e55e2b
commit
c259e77ca2
|
@ -0,0 +1 @@
|
||||||
|
Replace `AsPyPointer` with `AsRef<PyAny>` as a bound in the blanket implementation of `From<&T> for PyObject`
|
|
@ -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
|
impl<T> std::convert::From<&'_ T> for PyObject
|
||||||
where
|
where
|
||||||
T: AsPyPointer + PyNativeType,
|
T: PyNativeType + AsRef<PyAny>,
|
||||||
{
|
{
|
||||||
fn from(obj: &T) -> Self {
|
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()) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue