From eff2811aae2ca6d9029c901d149512c2a98ec373 Mon Sep 17 00:00:00 2001 From: Lily Foote Date: Sun, 23 Jun 2024 18:46:29 +0100 Subject: [PATCH] Replace unsafe call with safe methods --- src/instrumentation.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/instrumentation.rs b/src/instrumentation.rs index 0f09959f754..6a5463a304c 100644 --- a/src/instrumentation.rs +++ b/src/instrumentation.rs @@ -1,5 +1,6 @@ //! APIs wrapping the Python interpreter's instrumentation features. use crate::ffi; +use crate::ffi_ptr_ext::FfiPtrExt; use crate::pyclass::boolean_struct::False; use crate::types::PyFrame; use crate::{Bound, PyAny, PyClass, PyObject, PyRefMut, PyResult, Python}; @@ -82,7 +83,7 @@ where // We borrow the object so we don't break reference counting. // // https://docs.python.org/3/c-api/init.html#c.Py_tracefunc - let frame = unsafe { PyObject::from_borrowed_ptr(py, frame) }; + let frame = frame.assume_borrowed_unchecked(py).downcast_unchecked(); let frame = frame.extract(py).unwrap(); // Safety: