Skip to content

Commit

Permalink
fixup migration guide examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ngoldbaum committed Sep 3, 2024
1 parent e33212c commit fe0b5cd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions guide/src/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ was not needed in the first place.

Before:

```rust,ignore
```rust
# #[cfg(not(Py_GIL_DISABLED))] {
# use pyo3::prelude::*;
use pyo3::sync::GILProtected;
use pyo3::types::{PyDict, PyNone};
Expand All @@ -234,12 +235,13 @@ static OBJECTS: GILProtected<RefCell<Vec<Py<PyDict>>>> =

fn main() {
Python::with_gil(|py: Python| {
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();
OBJECTS.get(py).borrow_mut().push(d.unbind());
});
}
# }
```

After:
Expand All @@ -262,8 +264,8 @@ static OBJECTS: Mutex<Vec<Py<PyDict>>> = 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());
Expand Down

0 comments on commit fe0b5cd

Please sign in to comment.