Skip to content

Commit 417a5c5

Browse files
authored
rename Python::with_gil_unchecked as Python::attach_unchecked (#5340)
1 parent c5aacbd commit 417a5c5

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

newsfragments/5340.changed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rename `Python::with_gil_unchecked` to `Python::attach_unchecked`

src/marker.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,18 +465,32 @@ impl Python<'_> {
465465
crate::interpreter_lifecycle::initialize();
466466
}
467467

468+
/// See [Python::attach_unchecked]
469+
/// # Safety
470+
///
471+
/// If [`Python::attach`] would succeed, it is safe to call this function.
472+
#[inline]
473+
#[track_caller]
474+
#[deprecated(note = "use `Python::attach_unchecked` instead", since = "0.26.0")]
475+
pub unsafe fn with_gil_unchecked<F, R>(f: F) -> R
476+
where
477+
F: for<'py> FnOnce(Python<'py>) -> R,
478+
{
479+
unsafe { Self::attach_unchecked(f) }
480+
}
481+
468482
/// Like [`Python::attach`] except Python interpreter state checking is skipped.
469483
///
470-
/// Normally when the GIL is acquired, PyO3 checks that the Python interpreter is
471-
/// in an appropriate state (e.g. it is fully initialized). This function skips
484+
/// Normally when attaching to the Python interpreter, PyO3 checks that it is in
485+
/// an appropriate state (e.g. it is fully initialized). This function skips
472486
/// those checks.
473487
///
474488
/// # Safety
475489
///
476490
/// If [`Python::attach`] would succeed, it is safe to call this function.
477491
#[inline]
478492
#[track_caller]
479-
pub unsafe fn with_gil_unchecked<F, R>(f: F) -> R
493+
pub unsafe fn attach_unchecked<F, R>(f: F) -> R
480494
where
481495
F: for<'py> FnOnce(Python<'py>) -> R,
482496
{

0 commit comments

Comments
 (0)