Extend lifetime of GIL token associated with PyRef(Mut).
This commit is contained in:
parent
f9cb5e5cb0
commit
63a9093510
1
newsfragments/3131.changed.md
Normal file
1
newsfragments/3131.changed.md
Normal file
|
@ -0,0 +1 @@
|
|||
Extend the lifetime of the GIL token returned by `PyRef::py` and `PyRefMut::py` to match the underlying borrow.
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue