Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/5340.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rename `Python::with_gil_unchecked` to `Python::attach_unchecked`
20 changes: 17 additions & 3 deletions src/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,18 +465,32 @@ 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, R>(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
///
/// If [`Python::attach`] would succeed, it is safe to call this function.
#[inline]
#[track_caller]
pub unsafe fn with_gil_unchecked<F, R>(f: F) -> R
pub unsafe fn attach_unchecked<F, R>(f: F) -> R
where
F: for<'py> FnOnce(Python<'py>) -> R,
{
Expand Down
Loading