From 4dbb21174457f672162bab40bbe37586b6aaea05 Mon Sep 17 00:00:00 2001 From: David Hewitt <1939362+davidhewitt@users.noreply.github.com> Date: Sun, 22 Jan 2023 07:54:12 +0000 Subject: [PATCH] release: 0.18.0 --- CHANGELOG.md | 5 +++++ Cargo.toml | 6 +++--- src/de.rs | 14 +++++++------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27181f8..fe8a050 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.18.0 - 2022-08-24 + +- Add LICENSE file to the crate +- Update to PyO3 0.18 + ## 0.17.0 - 2022-08-24 - Update to PyO3 0.17 diff --git a/Cargo.toml b/Cargo.toml index f80e26d..97816a1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pythonize" -version = "0.17.0" +version = "0.18.0" authors = ["David Hewitt <1939362+davidhewitt@users.noreply.github.com>"] edition = "2018" license = "MIT" @@ -12,10 +12,10 @@ documentation = "https://docs.rs/crate/pythonize/" [dependencies] serde = { version = "1.0", default-features = false, features = ["std"] } -pyo3 = { version = "0.17.0", default-features = false } +pyo3 = { version = "0.18.0", default-features = false } [dev-dependencies] serde = { version = "1.0", default-features = false, features = ["derive"] } -pyo3 = { version = "0.17.0", default-features = false, features = ["auto-initialize", "macros"] } +pyo3 = { version = "0.18.0", default-features = false, features = ["auto-initialize", "macros"] } serde_json = "1.0" maplit = "1.0.2" diff --git a/src/de.rs b/src/de.rs index 197ca3e..c6a171f 100644 --- a/src/de.rs +++ b/src/de.rs @@ -107,7 +107,7 @@ impl<'a, 'de> de::Deserializer<'de> for &'a mut Depythonizer<'de> { where V: de::Visitor<'de>, { - let s = self.input.cast_as::()?.to_str()?; + let s = self.input.downcast::()?.to_str()?; if s.len() != 1 { return Err(PythonizeError::invalid_length_char()); } @@ -129,7 +129,7 @@ impl<'a, 'de> de::Deserializer<'de> for &'a mut Depythonizer<'de> { where V: de::Visitor<'de>, { - let s: &PyString = self.input.cast_as()?; + let s: &PyString = self.input.downcast()?; visitor.visit_str(s.to_str()?) } @@ -145,7 +145,7 @@ impl<'a, 'de> de::Deserializer<'de> for &'a mut Depythonizer<'de> { V: de::Visitor<'de>, { let obj = self.input; - let b: &PyBytes = obj.cast_as()?; + let b: &PyBytes = obj.downcast()?; visitor.visit_bytes(b.as_bytes()) } @@ -249,20 +249,20 @@ impl<'a, 'de> de::Deserializer<'de> for &'a mut Depythonizer<'de> { let item = self.input; if item.is_instance_of::()? { // Get the enum variant from the dict key - let d: &PyDict = item.cast_as().unwrap(); + let d: &PyDict = item.downcast().unwrap(); if d.len() != 1 { return Err(PythonizeError::invalid_length_enum()); } let variant: &PyString = d .keys() .get_item(0)? - .cast_as() + .downcast() .map_err(|_| PythonizeError::dict_key_not_string())?; let value = d.get_item(variant).unwrap(); let mut de = Depythonizer::from_object(value); visitor.visit_enum(PyEnumAccess::new(&mut de, variant)) } else if item.is_instance_of::()? { - let s: &PyString = self.input.cast_as()?; + let s: &PyString = self.input.downcast()?; visitor.visit_enum(s.to_str()?.into_deserializer()) } else { Err(PythonizeError::invalid_enum_type()) @@ -275,7 +275,7 @@ impl<'a, 'de> de::Deserializer<'de> for &'a mut Depythonizer<'de> { { let s: &PyString = self .input - .cast_as() + .downcast() .map_err(|_| PythonizeError::dict_key_not_string())?; visitor.visit_str(s.to_str()?) }