Browse Source

Merge pull request #1 from dora-rs/into_pyobject

Replace deprected pyo3 `to_object` call with `into_pyobject`
tags/v0.3.11-rc1
Shar-jeel-Sajid GitHub 10 months ago
parent
commit
76312a6994
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 3 deletions
  1. +10
    -2
      apis/python/node/src/lib.rs
  2. +8
    -1
      apis/python/operator/src/lib.rs

+ 10
- 2
apis/python/node/src/lib.rs View File

@@ -218,9 +218,9 @@ impl Node {
value
.to_pyarrow(py)
.context("failed to convert value to pyarrow")
.unwrap_or_else(|err| PyErr::from(err).to_object(py))
.unwrap_or_else(|err| err_to_pyany(err, py))
}),
Err(err) => Python::with_gil(|py| PyErr::from(err).to_object(py)),
Err(err) => Python::with_gil(|py| err_to_pyany(err, py)),
}
});
futures::pin_mut!(s);
@@ -239,6 +239,14 @@ impl Node {
}
}

fn err_to_pyany(err: eyre::Report, gil: Python<'_>) -> Py<PyAny> {
PyErr::from(err)
.into_pyobject(gil)
.unwrap_or_else(|infallible| match infallible {})
.into_any()
.unbind()
}

struct Events {
inner: EventsInner,
cleanup_handle: NodeCleanupHandle,


+ 8
- 1
apis/python/operator/src/lib.rs View File

@@ -140,7 +140,14 @@ impl PyEvent {
}

if let Some(cleanup) = self._cleanup.clone() {
pydict.insert("_cleanup", cleanup.into_py(py));
pydict.insert(
"_cleanup",
cleanup
.into_pyobject(py)
.context("failed to convert cleanup handle to pyobject")?
.into_any()
.unbind(),
);
}

Ok(pydict


Loading…
Cancel
Save