pyo3/tests/ui/wrong_aspyref_lifetimes.rs
Icxolu c359f5ca1d
deprecate PyDict::new constructor (#3823)
* deprecate `PyDict::new`

* update benchmarks

* convert `test_frompyobject`
2024-02-11 23:55:56 +00:00

11 lines
363 B
Rust

use pyo3::{types::PyDict, Bound, Py, Python};
fn main() {
let dict: Py<PyDict> = Python::with_gil(|py| PyDict::new_bound(py).unbind());
// Should not be able to get access to Py contents outside of with_gil.
let dict: &Bound<'_, PyDict> = Python::with_gil(|py| dict.bind(py));
let _py: Python = dict.py(); // Obtain a Python<'p> without GIL.
}