diff --git a/newsfragments/5109.changed.md b/newsfragments/5109.changed.md new file mode 100644 index 00000000000..0f46eb936e6 --- /dev/null +++ b/newsfragments/5109.changed.md @@ -0,0 +1 @@ +Add `#[track_caller]` to `with_gil` and `with_gil_unchecked`. diff --git a/src/marker.rs b/src/marker.rs index a4a7be8c0c5..fdc7b32ec00 100644 --- a/src/marker.rs +++ b/src/marker.rs @@ -399,6 +399,7 @@ impl Python<'_> { /// /// [`auto-initialize`]: https://pyo3.rs/main/features.html#auto-initialize #[inline] + #[track_caller] pub fn with_gil(f: F) -> R where F: for<'py> FnOnce(Python<'py>) -> R, @@ -433,6 +434,7 @@ impl Python<'_> { /// /// Behavior in other scenarios is not documented. #[inline] + #[track_caller] pub unsafe fn with_gil_unchecked(f: F) -> R where F: for<'py> FnOnce(Python<'py>) -> R,