Skip to content

Commit 5a3de05

Browse files
authored
Add #[track_caller] to with_gil. (PyO3#5109)
* Add #[track_caller] to with_gil. * Add newsfragment.
1 parent 3c2c884 commit 5a3de05

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

newsfragments/5109.changed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add `#[track_caller]` to `with_gil` and `with_gil_unchecked`.

src/marker.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ impl Python<'_> {
399399
///
400400
/// [`auto-initialize`]: https://pyo3.rs/main/features.html#auto-initialize
401401
#[inline]
402+
#[track_caller]
402403
pub fn with_gil<F, R>(f: F) -> R
403404
where
404405
F: for<'py> FnOnce(Python<'py>) -> R,
@@ -433,6 +434,7 @@ impl Python<'_> {
433434
///
434435
/// Behavior in other scenarios is not documented.
435436
#[inline]
437+
#[track_caller]
436438
pub unsafe fn with_gil_unchecked<F, R>(f: F) -> R
437439
where
438440
F: for<'py> FnOnce(Python<'py>) -> R,

0 commit comments

Comments
 (0)