any reason Py::from_owned_ptr_or_err
is unsafe but all function it calls are safe?
#4208
-
unsafe {
return Py::from_owned_ptr_or_err(self.py, ptr);
} equal to return match NonNull::new(ptr) {
Some(nonnull_ptr) => Ok(Py(nonnull_ptr, PhantomData)),
None => Err(PyErr::fetch(self.py)),
}; |
Beta Was this translation helpful? Give feedback.
Answered by
adamreichold
May 26, 2024
Replies: 1 comment 1 reply
-
Being non-null is not sufficient for a pointer to point to a valid object in the Python heap. It could be dangling or not point into the Python heap at all. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
trim21
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Being non-null is not sufficient for a pointer to point to a valid object in the Python heap. It could be dangling or not point into the Python heap at all.