-
Notifications
You must be signed in to change notification settings - Fork 494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: upgrade pyo3 to 0.23 #5368
Conversation
What do you want to do for AsyncLister in this PR? |
Originally it was intended to continue to change towards this, Updated now. |
Here is a patch to simplify this PR (I can't push to your branch): commit 7590c5f11c04a63a85ef32f4e5e818024acb34a4
Author: messense <[email protected]>
Date: Mon Dec 2 13:26:59 2024 +0000
simplify
diff --git a/bindings/python/src/file.rs b/bindings/python/src/file.rs
index 8cfcbf51..2c217232 100644
--- a/bindings/python/src/file.rs
+++ b/bindings/python/src/file.rs
@@ -470,8 +470,7 @@ impl AsyncFile {
.map_err(|err| PyIOError::new_err(err.to_string()))?;
Ok(pos)
})
- .and_then(|pos| pos.into_pyobject(py).map_err(Into::into))
- .map(|pyobj| pyobj.into_any())
+ .and_then(|pos| pos.into_bound_py_any(py))
}
/// Return the current stream position.
@@ -500,8 +499,7 @@ impl AsyncFile {
.map_err(|err| PyIOError::new_err(err.to_string()))?;
Ok(pos)
})
- .and_then(|pos| pos.into_pyobject(py).map_err(Into::into))
- .map(|pyobj| pyobj.into_any())
+ .and_then(|pos| pos.into_bound_py_any(py))
}
fn close<'p>(&'p mut self, py: Python<'p>) -> PyResult<Bound<PyAny>> {
diff --git a/bindings/python/src/lister.rs b/bindings/python/src/lister.rs
index 55e08bef..6019689d 100644
--- a/bindings/python/src/lister.rs
+++ b/bindings/python/src/lister.rs
@@ -42,12 +42,7 @@ impl BlockingLister {
}
fn __next__(mut slf: PyRefMut<'_, Self>) -> PyResult<Option<PyObject>> {
match slf.0.next() {
- Some(Ok(entry)) => Ok(Some(
- Entry::new(entry)
- .into_pyobject(slf.py())?
- .into_any()
- .unbind(),
- )),
+ Some(Ok(entry)) => Ok(Some(Entry::new(entry).into_py_any(slf.py())?)),
Some(Err(err)) => {
let pyerr = format_pyerr(err);
Err(pyerr)
diff --git a/bindings/python/src/operator.rs b/bindings/python/src/operator.rs
index 995f3b74..76cdb09f 100644
--- a/bindings/python/src/operator.rs
+++ b/bindings/python/src/operator.rs
@@ -230,9 +230,9 @@ impl Operator {
fn __getnewargs_ex__(&self, py: Python) -> PyResult<PyObject> {
let args = vec![self.__scheme.to_string()];
- let args = PyTuple::new(py, args)?.into_any().unbind();
+ let args = PyTuple::new(py, args)?.into_py_any(py)?;
let kwargs = self.__map.clone().into_py_any(py)?;
- Ok(PyTuple::new(py, [args, kwargs])?.into_any().unbind())
+ Ok(PyTuple::new(py, [args, kwargs])?.into_py_any(py)?)
}
}
@@ -435,13 +435,7 @@ impl AsyncOperator {
let this = self.core.clone();
future_into_py(py, async move {
let lister = this.lister(&path).await.map_err(format_pyerr)?;
-
- let pylister = Python::with_gil(|py| {
- AsyncLister::new(lister)
- .into_pyobject(py)
- .map_err(|err| PyErr::new::<pyo3::exceptions::PyException, _>(err.to_string()))
- .map(|py_obj| py_obj.into_any().unbind())
- })?;
+ let pylister = Python::with_gil(|py| AsyncLister::new(lister).into_py_any(py))?;
Ok(pylister)
})
@@ -456,12 +450,8 @@ impl AsyncOperator {
.recursive(true)
.await
.map_err(format_pyerr)?;
- let pylister: PyObject = Python::with_gil(|py| {
- AsyncLister::new(lister)
- .into_pyobject(py)
- .map_err(|err| PyErr::new::<pyo3::exceptions::PyException, _>(err.to_string()))
- .map(|py_obj| py_obj.into_any().unbind())
- })?;
+ let pylister: PyObject =
+ Python::with_gil(|py| AsyncLister::new(lister).into_py_any(py))?;
Ok(pylister)
})
}
@@ -559,7 +549,7 @@ impl AsyncOperator {
let args = vec![self.__scheme.to_string()];
let args = PyTuple::new(py, args)?.into_py_any(py)?;
let kwargs = self.__map.clone().into_py_any(py)?;
- Ok(PyTuple::new(py, [args, kwargs])?.into_any().unbind())
+ Ok(PyTuple::new(py, [args, kwargs])?.into_py_any(py)?)
}
}
you can save it to a file say |
thank you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Which issue does this PR close?
Closes #5336.
Sorry, my skills are limited and I may not have made the changes correctly.
However, all the tests have passed, but I still don't know how to make the changes here. Can someone help me?
opendal/bindings/python/src/lister.rs