Skip to content

Commit 1bd7a3d

Browse files
Bump the minor-patch-dependencies group across 1 directory with 3 updates (#98)
* Bump the minor-patch-dependencies group across 1 directory with 3 updates Bumps the minor-patch-dependencies group with 3 updates in the / directory: [serde](https://github.com/serde-rs/serde), [serde_json](https://github.com/serde-rs/json) and [pyo3](https://github.com/pyo3/pyo3). Updates `serde` from 1.0.196 to 1.0.210 - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](serde-rs/serde@v1.0.196...v1.0.210) Updates `serde_json` from 1.0.113 to 1.0.128 - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](serde-rs/json@v1.0.113...1.0.128) Updates `pyo3` from 0.19.2 to 0.21.2 - [Release notes](https://github.com/pyo3/pyo3/releases) - [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md) - [Commits](PyO3/pyo3@v0.19.2...v0.21.2) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch dependency-group: minor-patch-dependencies - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch dependency-group: minor-patch-dependencies - dependency-name: pyo3 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: minor-patch-dependencies ... Signed-off-by: dependabot[bot] <[email protected]> * Remove deprecated cast_as() * Fix error about OperatingSystem::Aix * Fix cast inference --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Mathieu Leplatre <[email protected]>
1 parent d9503a3 commit 1bd7a3d

File tree

3 files changed

+52
-33
lines changed

3 files changed

+52
-33
lines changed

Cargo.lock

Lines changed: 40 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ serde_json = "1.0"
1717
canonical_json = "0.5.0"
1818

1919
[dependencies.pyo3]
20-
version = "0.19.2"
20+
version = "0.21.2"
2121
features = ["extension-module"]

src/lib.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ pub fn dumps(py: Python, obj: PyObject) -> PyResult<PyObject> {
8787
fn to_json(py: Python, obj: &PyObject) -> Result<serde_json::Value, PyCanonicalJSONError> {
8888
macro_rules! return_cast {
8989
($t:ty, $f:expr) => {
90-
if let Ok(val) = obj.cast_as::<$t>(py) {
90+
if let Ok(val) = obj.downcast::<$t>(py) {
9191
return $f(val);
9292
}
9393
};
@@ -142,14 +142,17 @@ fn to_json(py: Python, obj: &PyObject) -> Result<serde_json::Value, PyCanonicalJ
142142
Ok(serde_json::Value::Object(map))
143143
});
144144

145-
return_cast!(PyList, |x: &PyList| Ok(serde_json::Value::Array(r#try!(x
146-
.iter()
147-
.map(|x| to_json(py, &x.to_object(py)))
148-
.collect()))));
145+
return_cast!(PyList, |x: &PyList| {
146+
let json_array: Result<Vec<_>, _> =
147+
x.iter().map(|x| to_json(py, &x.to_object(py))).collect(); // This turns the iterator into a Result<Vec<Value>, PyCanonicalJSONError>
148+
Ok(serde_json::Value::Array(json_array?))
149+
});
149150

150-
return_cast!(PyTuple, |x: &PyTuple| Ok(serde_json::Value::Array(r#try!(
151-
x.iter().map(|x| to_json(py, &x.to_object(py))).collect()
152-
))));
151+
return_cast!(PyTuple, |x: &PyTuple| {
152+
let json_array: Result<Vec<_>, _> =
153+
x.iter().map(|x| to_json(py, &x.to_object(py))).collect(); // This turns the iterator into a Result<Vec<Value>, PyCanonicalJSONError>
154+
Ok(serde_json::Value::Array(json_array?))
155+
});
153156

154157
return_cast!(PyFloat, |x: &PyFloat| {
155158
match serde_json::Number::from_f64(x.value()) {

0 commit comments

Comments
 (0)