diff --git a/pyo3-bytes/Cargo.toml b/pyo3-bytes/Cargo.toml index c6c405fe..85ee5422 100644 --- a/pyo3-bytes/Cargo.toml +++ b/pyo3-bytes/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pyo3-bytes" -version = "0.4.0" +version = "0.5.0" authors = [ "Kyle Barron ", "jesse rubin ", @@ -17,7 +17,7 @@ rust-version = "1.75" [dependencies] # https://github.com/tokio-rs/bytes/releases/tag/v1.10.1 bytes = "1.10.1" -pyo3 = "0.26" +pyo3 = "0.27" [lib] crate-type = ["rlib"] diff --git a/pyo3-bytes/README.md b/pyo3-bytes/README.md index 8bd1696b..84cd563a 100644 --- a/pyo3-bytes/README.md +++ b/pyo3-bytes/README.md @@ -67,3 +67,4 @@ an idea, create an issue to discuss. | 0.2.x | 0.24 | | 0.3.x | 0.25 | | 0.4.x | 0.26 | +| 0.5.x | 0.27 | diff --git a/pyo3-bytes/src/bytes.rs b/pyo3-bytes/src/bytes.rs index d93d049b..b1c55367 100644 --- a/pyo3-bytes/src/bytes.rs +++ b/pyo3-bytes/src/bytes.rs @@ -406,9 +406,11 @@ impl PyBytes { } } -impl<'py> FromPyObject<'py> for PyBytes { - fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult { - let buffer = ob.extract::()?; +impl<'py> FromPyObject<'_, 'py> for PyBytes { + type Error = PyErr; + + fn extract(obj: Borrowed<'_, 'py, PyAny>) -> Result { + let buffer = obj.extract::()?; let bytes = Bytes::from_owner(buffer); Ok(Self(bytes)) } @@ -452,9 +454,11 @@ fn validate_buffer(buf: &PyBuffer) -> PyResult<()> { Ok(()) } -impl<'py> FromPyObject<'py> for PyBytesWrapper { - fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult { - let buffer = ob.extract::>()?; +impl<'py> FromPyObject<'_, 'py> for PyBytesWrapper { + type Error = PyErr; + + fn extract(obj: Borrowed<'_, 'py, PyAny>) -> Result { + let buffer = obj.extract::>()?; validate_buffer(&buffer)?; Ok(Self(buffer)) }