Remove usage of AsPyPointer
in traits for convergint to PyObject
Refs #3358
This commit is contained in:
parent
82b1e55e2b
commit
c259e77ca2
1
newsfragments/3391.changed.md
Normal file
1
newsfragments/3391.changed.md
Normal file
|
@ -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
|
||||
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()) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue