Skip to content

Commit

Permalink
release: 0.18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt committed Jan 22, 2023
1 parent 9ccecfd commit 4dbb211
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pythonize"
version = "0.17.0"
version = "0.18.0"
authors = ["David Hewitt <[email protected]>"]
edition = "2018"
license = "MIT"
Expand All @@ -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"
14 changes: 7 additions & 7 deletions src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<PyString>()?.to_str()?;
let s = self.input.downcast::<PyString>()?.to_str()?;
if s.len() != 1 {
return Err(PythonizeError::invalid_length_char());
}
Expand All @@ -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()?)
}

Expand All @@ -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())
}

Expand Down Expand Up @@ -249,20 +249,20 @@ impl<'a, 'de> de::Deserializer<'de> for &'a mut Depythonizer<'de> {
let item = self.input;
if item.is_instance_of::<PyDict>()? {
// 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::<PyString>()? {
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())
Expand All @@ -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()?)
}
Expand Down

0 comments on commit 4dbb211

Please sign in to comment.