Skip to content

Commit

Permalink
Bump pyo3 to 0.20.
Browse files Browse the repository at this point in the history
  • Loading branch information
jelmer committed Jun 25, 2024
1 parent b51ff35 commit 6f55eee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ serde = [ "dep:serde",]
lazy-regex = "3"

[dependencies.pyo3]
version = ">=0.17"
version = ">=0.20"
optional = true

[dependencies.sqlx]
Expand All @@ -39,5 +39,5 @@ default-features = false
features = [ "runtime-async-std-native-tls",]

[dev-dependencies.pyo3]
version = ">=0.17"
version = ">=0.20"
features = [ "auto-initialize",]
16 changes: 8 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,10 +585,10 @@ use pyo3::prelude::*;

#[cfg(feature = "python-debian")]
impl FromPyObject<'_> for Version {
fn extract(ob: &PyAny) -> PyResult<Self> {
let debian_support = Python::import(ob.py(), "debian.debian_support")?;
fn extract_bound(ob: &Bound<PyAny>) -> PyResult<Self> {
let debian_support = Python::import_bound(ob.py(), "debian.debian_support")?;
let version_cls = debian_support.getattr("Version")?;
if !ob.is_instance(version_cls)? {
if !ob.is_instance(&version_cls)? {
return Err(pyo3::exceptions::PyTypeError::new_err("Expected a Version"));
}
Ok(Version {
Expand All @@ -605,7 +605,7 @@ impl FromPyObject<'_> for Version {
#[cfg(feature = "python-debian")]
impl ToPyObject for Version {
fn to_object(&self, py: Python) -> PyObject {
let debian_support = py.import("debian.debian_support").unwrap();
let debian_support = py.import_bound("debian.debian_support").unwrap();
let version_cls = debian_support.getattr("Version").unwrap();
version_cls
.call1((self.to_string(),))
Expand All @@ -629,15 +629,15 @@ mod python_tests {
use pyo3::prelude::*;

Python::with_gil(|py| {
let globals = pyo3::types::PyDict::new(py);
let globals = pyo3::types::PyDict::new_bound(py);
globals
.set_item(
"debian_support",
py.import("debian.debian_support").unwrap(),
py.import_bound("debian.debian_support").unwrap(),
)
.unwrap();
let v = py
.eval("debian_support.Version('1.0-1')", Some(globals), None)
.eval_bound("debian_support.Version('1.0-1')", Some(&globals), None)
.unwrap()
.extract::<Version>()
.unwrap();
Expand Down Expand Up @@ -666,7 +666,7 @@ mod python_tests {
let v = v.to_object(py);
let expected: Version = "1:1.0-1".parse().unwrap();
assert_eq!(v.extract::<Version>(py).unwrap(), expected);
assert_eq!(v.as_ref(py).get_type().name().unwrap(), "Version");
assert_eq!(v.bind(py).get_type().name().unwrap(), "Version");
});
}
}
Expand Down

0 comments on commit 6f55eee

Please sign in to comment.