Skip to content

Commit

Permalink
Extend lifetime of GIL token associated with PyRef(Mut).
Browse files Browse the repository at this point in the history
  • Loading branch information
adamreichold committed May 1, 2023
1 parent f9cb5e5 commit 912b9e4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/pycell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,8 @@ pub struct PyRef<'p, T: PyClass> {

impl<'p, T: PyClass> PyRef<'p, T> {
/// Returns a `Python` token that is bound to the lifetime of the `PyRef`.
pub fn py(&self) -> Python<'_> {
unsafe { Python::assume_gil_acquired() }
pub fn py(&self) -> Python<'p> {
self.inner.py()
}
}

Expand Down Expand Up @@ -706,8 +706,8 @@ pub struct PyRefMut<'p, T: PyClass<Frozen = False>> {

impl<'p, T: PyClass<Frozen = False>> PyRefMut<'p, T> {
/// Returns a `Python` token that is bound to the lifetime of the `PyRefMut`.
pub fn py(&self) -> Python<'_> {
unsafe { Python::assume_gil_acquired() }
pub fn py(&self) -> Python<'p> {
self.inner.py()
}
}

Expand Down

0 comments on commit 912b9e4

Please sign in to comment.