pyo3/tests/ui/wrong_aspyref_lifetimes.rs

11 lines
339 B
Rust
Raw Normal View History

2021-08-01 21:41:32 +00:00
use pyo3::{types::PyDict, Py, Python};
fn main() {
2023-02-22 21:46:42 +00:00
let dict: Py<PyDict> = Python::with_gil(|py| PyDict::new(py).into());
// Should not be able to get access to Py contents outside of with_gil.
let dict: &PyDict = Python::with_gil(|py| dict.as_ref(py));
let _py: Python = dict.py(); // Obtain a Python<'p> without GIL.
}