Skip to content

Commit 40804b4

Browse files
committed
Update to PyO3 0.22.
1 parent de84e08 commit 40804b4

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ autoexamples = false
1414

1515
[dependencies]
1616
inline-python-macros = { version = "=0.12.0", path = "./macros" }
17-
pyo3 = { version = "0.21", default-features = false, features = ["auto-initialize"] }
17+
pyo3 = { version = "0.22", default-features = false, features = ["auto-initialize"] }
1818

1919
[workspace]
2020
members = ["examples", "ct-python"]

examples/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ path = "rust-fn.rs"
1717

1818
[dependencies]
1919
inline-python = { path = ".." }
20-
pyo3 = "0.21"
20+
pyo3 = "0.22"

macros/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ proc_macro = true
1616
[dependencies]
1717
proc-macro2 = { version = "1.0", features = ["span-locations"] }
1818
quote = "1.0"
19-
pyo3 = { version = "0.21", default-features = false, features = ["auto-initialize"] }
19+
pyo3 = { version = "0.22", default-features = false, features = ["auto-initialize"] }
2020

2121
[target.'cfg(unix)'.dependencies]
2222
libc = "0.2.71"

src/context.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,14 @@ impl Context {
155155
///
156156
/// This function temporarily acquires the GIL.
157157
/// If you already have the GIL, you can use [`Context::add_wrapped_with_gil`] instead.
158-
pub fn add_wrapped(&self, wrapper: &impl Fn(Python) -> PyResult<&PyCFunction>) {
158+
pub fn add_wrapped(&self, wrapper: &impl Fn(Python) -> PyResult<Bound<'_, PyCFunction>>) {
159159
Python::with_gil(|py| self.add_wrapped_with_gil(py, wrapper));
160160
}
161161

162162
/// Add a wrapped `#[pyfunction]` or `#[pymodule]` using its own `__name__`.
163163
///
164164
/// See [Context::add_wrapped].
165-
pub fn add_wrapped_with_gil<'p>(&self, py: Python<'p>, wrapper: &impl Fn(Python) -> PyResult<&PyCFunction>) {
165+
pub fn add_wrapped_with_gil<'p>(&self, py: Python<'p>, wrapper: &impl Fn(Python) -> PyResult<Bound<'_, PyCFunction>>) {
166166
let obj = wrapper(py).unwrap();
167167
let name = obj.getattr("__name__").expect("Missing __name__");
168168
self.set_with_gil(py, name.extract().unwrap(), obj)

src/run.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use crate::Context;
2-
use pyo3::{ffi, types::PyAny, PyObject, PyResult, Python};
2+
use pyo3::{ffi, types::PyAny, Bound, PyObject, PyResult, Python};
33

4-
pub fn run_python_code<'p>(py: Python<'p>, context: &Context, bytecode: &[u8]) -> PyResult<&'p PyAny> {
4+
pub fn run_python_code<'p>(py: Python<'p>, context: &Context, bytecode: &[u8]) -> PyResult<Bound<'p, PyAny>> {
55
unsafe {
66
let ptr = ffi::PyMarshal_ReadObjectFromString(bytecode.as_ptr() as *const _, bytecode.len() as isize);
77
let code = PyObject::from_owned_ptr_or_err(py, ptr)?;
88
let result = ffi::PyEval_EvalCode(code.as_ptr(), context.globals.as_ptr(), std::ptr::null_mut());
9-
py.from_owned_ptr_or_err(result)
9+
Bound::from_owned_ptr_or_err(py, result)
1010
}
1111
}

0 commit comments

Comments
 (0)