diff --git a/guide/src/migration.md b/guide/src/migration.md index dfc9bd4e406..4e97862a993 100644 --- a/guide/src/migration.md +++ b/guide/src/migration.md @@ -223,7 +223,9 @@ was not needed in the first place. Before: -```rust,ignore +```rust +# fn main() { +# #[cfg(not(Py_GIL_DISABLED))] { # use pyo3::prelude::*; use pyo3::sync::GILProtected; use pyo3::types::{PyDict, PyNone}; @@ -232,14 +234,13 @@ use std::cell::RefCell; static OBJECTS: GILProtected>>> = GILProtected::new(RefCell::new(Vec::new())); -fn main() { - Python::with_gil(|py: Python| { - let d = PyDict::new(py); - // stand-in for something that executes arbitrary python code - d.set_item(PyNone::get(py), PyNone::get(py)).unwrap(); - OBJECTS.get(py).borrow_mut().push(d.unbind()); - }); -} +Python::with_gil(|py| { + // stand-in for something that executes arbitrary python code + let d = PyDict::new(py); + d.set_item(PyNone::get(py), PyNone::get(py)).unwrap(); + OBJECTS.get(py).borrow_mut().push(d.unbind()); +}); +# }} ``` After: @@ -262,8 +263,8 @@ static OBJECTS: Mutex>> = Mutex::new(Vec::new()); fn main() { Python::with_gil(|py| { - let d = PyDict::new(py); // stand-in for something that executes arbitrary python code + let d = PyDict::new(py); d.set_item(PyNone::get(py), PyNone::get(py)).unwrap(); #[cfg(not(Py_GIL_DISABLED))] OBJECTS.get(py).borrow_mut().push(d.unbind());