diff --git a/python/Cargo.lock b/python/Cargo.lock index 18b47ad..2f467f8 100644 --- a/python/Cargo.lock +++ b/python/Cargo.lock @@ -981,9 +981,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.26.0" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ba0117f4212101ee6544044dae45abe1083d30ce7b29c4b5cbdfa2354e07383" +checksum = "37a6df7eab65fc7bee654a421404947e10a0f7085b6951bf2ea395f4659fb0cf" dependencies = [ "chrono", "indexmap", @@ -1000,9 +1000,9 @@ dependencies = [ [[package]] name = "pyo3-async-runtimes" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6ee6d4cb3e8d5b925f5cdb38da183e0ff18122eb2048d4041c9e7034d026e23" +checksum = "57ddb5b570751e93cc6777e81fee8087e59cd53b5043292f2a6d59d5bd80fdfd" dependencies = [ "futures", "once_cell", @@ -1013,18 +1013,18 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.26.0" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fc6ddaf24947d12a9aa31ac65431fb1b851b8f4365426e182901eabfb87df5f" +checksum = "f77d387774f6f6eec64a004eac0ed525aab7fa1966d94b42f743797b3e395afb" dependencies = [ "target-lexicon", ] [[package]] name = "pyo3-bytes" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f01f356a8686c821ce6ec5ac74a442ffbda3ce1fb26a113d4120fd78faf9f726" +checksum = "37248130b5b50c06a3bd2ed0a4e763aff9bf3104991c656bc27c303df0889460" dependencies = [ "bytes", "pyo3", @@ -1032,9 +1032,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.26.0" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "025474d3928738efb38ac36d4744a74a400c901c7596199e20e45d98eb194105" +checksum = "2dd13844a4242793e02df3e2ec093f540d948299a6a77ea9ce7afd8623f542be" dependencies = [ "libc", "pyo3-build-config", @@ -1042,9 +1042,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.26.0" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e64eb489f22fe1c95911b77c44cc41e7c19f3082fc81cce90f657cdc42ffded" +checksum = "eaf8f9f1108270b90d3676b8679586385430e5c0bb78bb5f043f95499c821a71" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -1054,9 +1054,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.26.0" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "100246c0ecf400b475341b8455a9213344569af29a3c841d29270e53102e0fcf" +checksum = "70a3b2274450ba5288bc9b8c1b69ff569d1d61189d4bff38f8d22e03d17f932b" dependencies = [ "heck", "proc-macro2", @@ -1067,9 +1067,9 @@ dependencies = [ [[package]] name = "pyo3-object_store" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cda46869b9ce0e94ca68a8c2f48fdc940a543ed5e2d9272c3e7cc4bcc579fd6" +checksum = "5ef5552f108a4d65b78c924b27513471a9ba425341ada4be5ea0ca53806ae316" dependencies = [ "async-trait", "bytes", diff --git a/python/Cargo.toml b/python/Cargo.toml index d5f2fd3..c8948d9 100644 --- a/python/Cargo.toml +++ b/python/Cargo.toml @@ -25,10 +25,10 @@ async-tiff = { path = "../" } bytes = "1.10.1" futures = "0.3.31" object_store = "0.12" -pyo3 = { version = "0.26.0", features = ["macros"] } -pyo3-async-runtimes = "0.26" -pyo3-bytes = "0.4" -pyo3-object_store = "0.6.0" +pyo3 = { version = "0.27.0", features = ["macros"] } +pyo3-async-runtimes = "0.27" +pyo3-bytes = "0.5" +pyo3-object_store = "0.7.0" rayon = "1.11.0" tokio-rayon = "2.1.0" thiserror = "1" diff --git a/python/src/decoder.rs b/python/src/decoder.rs index 0712e8e..2810e64 100644 --- a/python/src/decoder.rs +++ b/python/src/decoder.rs @@ -60,14 +60,16 @@ impl PyDecoder { } } -impl<'py> FromPyObject<'py> for PyDecoder { - fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult { - if !ob.hasattr(intern!(ob.py(), "__call__"))? { +impl<'py> FromPyObject<'_, 'py> for PyDecoder { + type Error = PyErr; + + fn extract(obj: Borrowed<'_, 'py, PyAny>) -> Result { + if !obj.hasattr(intern!(obj.py(), "__call__"))? { return Err(PyTypeError::new_err( "Expected callable object for custom decoder.", )); } - Ok(Self(ob.clone().unbind())) + Ok(Self(obj.as_unbound().clone_ref(obj.py()))) } } diff --git a/python/src/enums.rs b/python/src/enums.rs index 14656bd..e3a6de7 100644 --- a/python/src/enums.rs +++ b/python/src/enums.rs @@ -21,9 +21,11 @@ impl From for CompressionMethod { } } -impl<'py> FromPyObject<'py> for PyCompressionMethod { - fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult { - Ok(Self(CompressionMethod::from_u16_exhaustive(ob.extract()?))) +impl<'py> FromPyObject<'_, 'py> for PyCompressionMethod { + type Error = PyErr; + + fn extract(obj: Borrowed<'_, 'py, PyAny>) -> Result { + Ok(Self(CompressionMethod::from_u16_exhaustive(obj.extract()?))) } } diff --git a/python/src/reader.rs b/python/src/reader.rs index da61124..86c5095 100644 --- a/python/src/reader.rs +++ b/python/src/reader.rs @@ -95,13 +95,15 @@ impl ObspecBackend { } } -impl<'py> FromPyObject<'py> for ObspecBackend { - fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult { - let py = ob.py(); - if ob.hasattr(intern!(py, "get_range_async"))? - && ob.hasattr(intern!(py, "get_ranges_async"))? +impl<'py> FromPyObject<'_, 'py> for ObspecBackend { + type Error = PyErr; + + fn extract(obj: Borrowed<'_, 'py, PyAny>) -> Result { + let py = obj.py(); + if obj.hasattr(intern!(py, "get_range_async"))? + && obj.hasattr(intern!(py, "get_ranges_async"))? { - Ok(Self(ob.clone().unbind())) + Ok(Self(obj.as_unbound().clone_ref(py))) } else { Err(PyTypeError::new_err("Expected obspec-compatible class with `get_range_async` and `get_ranges_async` method.")) }