diff --git a/newsfragments/5340.changed.md b/newsfragments/5340.changed.md new file mode 100644 index 00000000000..ba669356a06 --- /dev/null +++ b/newsfragments/5340.changed.md @@ -0,0 +1 @@ +rename `Python::with_gil_unchecked` to `Python::attach_unchecked` \ No newline at end of file diff --git a/src/marker.rs b/src/marker.rs index 8f8b48d983a..a9a7e378964 100644 --- a/src/marker.rs +++ b/src/marker.rs @@ -465,10 +465,24 @@ impl Python<'_> { crate::interpreter_lifecycle::initialize(); } + /// See [Python::attach_unchecked] + /// # Safety + /// + /// If [`Python::attach`] would succeed, it is safe to call this function. + #[inline] + #[track_caller] + #[deprecated(note = "use `Python::attach_unchecked` instead", since = "0.26.0")] + pub unsafe fn with_gil_unchecked(f: F) -> R + where + F: for<'py> FnOnce(Python<'py>) -> R, + { + unsafe { Self::attach_unchecked(f) } + } + /// Like [`Python::attach`] except Python interpreter state checking is skipped. /// - /// Normally when the GIL is acquired, PyO3 checks that the Python interpreter is - /// in an appropriate state (e.g. it is fully initialized). This function skips + /// Normally when attaching to the Python interpreter, PyO3 checks that it is in + /// an appropriate state (e.g. it is fully initialized). This function skips /// those checks. /// /// # Safety @@ -476,7 +490,7 @@ impl Python<'_> { /// If [`Python::attach`] would succeed, it is safe to call this function. #[inline] #[track_caller] - pub unsafe fn with_gil_unchecked(f: F) -> R + pub unsafe fn attach_unchecked(f: F) -> R where F: for<'py> FnOnce(Python<'py>) -> R, {