Skip to content

Commit 663c613

Browse files
authored
Merge pull request #28 from davidhewitt/release-0.17.0
release: 0.17.0
2 parents ba1d0ec + 8d49643 commit 663c613

File tree

4 files changed

+40
-34
lines changed

4 files changed

+40
-34
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.17.0 - 2022-08-24
2+
3+
- Update to PyO3 0.17
4+
15
## 0.16.0 - 2022-03-06
26

37
- Update to PyO3 0.16

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pythonize"
3-
version = "0.16.0"
3+
version = "0.17.0"
44
authors = ["David Hewitt <[email protected]>"]
55
edition = "2018"
66
license = "MIT"
@@ -12,10 +12,10 @@ documentation = "https://docs.rs/crate/pythonize/"
1212

1313
[dependencies]
1414
serde = { version = "1.0", default-features = false, features = ["std"] }
15-
pyo3 = { version = "0.16.3", default-features = false }
15+
pyo3 = { version = "0.17.0", default-features = false }
1616

1717
[dev-dependencies]
1818
serde = { version = "1.0", default-features = false, features = ["derive"] }
19-
pyo3 = { version = "0.16.3", default-features = false, features = ["auto-initialize", "macros", "pyproto"] }
19+
pyo3 = { version = "0.17.0", default-features = false, features = ["auto-initialize", "macros"] }
2020
serde_json = "1.0"
2121
maplit = "1.0.2"

src/de.rs

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -433,16 +433,16 @@ mod test {
433433
where
434434
T: de::DeserializeOwned + PartialEq + std::fmt::Debug,
435435
{
436-
let gil = Python::acquire_gil();
437-
let py = gil.python();
438-
let locals = PyDict::new(py);
439-
py.run(&format!("obj = {}", code), None, Some(locals))
440-
.unwrap();
441-
let obj = locals.get_item("obj").unwrap();
442-
let actual: T = depythonize(obj).unwrap();
443-
assert_eq!(&actual, expected);
444-
let actual_json: JsonValue = depythonize(obj).unwrap();
445-
assert_eq!(&actual_json, expected_json);
436+
Python::with_gil(|py| {
437+
let locals = PyDict::new(py);
438+
py.run(&format!("obj = {}", code), None, Some(locals))
439+
.unwrap();
440+
let obj = locals.get_item("obj").unwrap();
441+
let actual: T = depythonize(obj).unwrap();
442+
assert_eq!(&actual, expected);
443+
let actual_json: JsonValue = depythonize(obj).unwrap();
444+
assert_eq!(&actual_json, expected_json);
445+
});
446446
}
447447

448448
#[test]
@@ -489,16 +489,16 @@ mod test {
489489

490490
let code = "{'foo': 'Foo'}";
491491

492-
let gil = Python::acquire_gil();
493-
let py = gil.python();
494-
let locals = PyDict::new(py);
495-
py.run(&format!("obj = {}", code), None, Some(locals))
496-
.unwrap();
497-
let obj = locals.get_item("obj").unwrap();
498-
assert!(matches!(
499-
*depythonize::<Struct>(obj).unwrap_err().inner,
500-
ErrorImpl::Message(msg) if msg == "missing field `bar`"
501-
));
492+
Python::with_gil(|py| {
493+
let locals = PyDict::new(py);
494+
py.run(&format!("obj = {}", code), None, Some(locals))
495+
.unwrap();
496+
let obj = locals.get_item("obj").unwrap();
497+
assert!(matches!(
498+
*depythonize::<Struct>(obj).unwrap_err().inner,
499+
ErrorImpl::Message(msg) if msg == "missing field `bar`"
500+
));
501+
})
502502
}
503503

504504
#[test]
@@ -519,16 +519,16 @@ mod test {
519519

520520
let code = "('cat', -10.05, 'foo')";
521521

522-
let gil = Python::acquire_gil();
523-
let py = gil.python();
524-
let locals = PyDict::new(py);
525-
py.run(&format!("obj = {}", code), None, Some(locals))
526-
.unwrap();
527-
let obj = locals.get_item("obj").unwrap();
528-
assert!(matches!(
529-
*depythonize::<TupleStruct>(obj).unwrap_err().inner,
530-
ErrorImpl::IncorrectSequenceLength { expected, got } if expected == 2 && got == 3
531-
));
522+
Python::with_gil(|py| {
523+
let locals = PyDict::new(py);
524+
py.run(&format!("obj = {}", code), None, Some(locals))
525+
.unwrap();
526+
let obj = locals.get_item("obj").unwrap();
527+
assert!(matches!(
528+
*depythonize::<TupleStruct>(obj).unwrap_err().inner,
529+
ErrorImpl::IncorrectSequenceLength { expected, got } if expected == 2 && got == 3
530+
));
531+
})
532532
}
533533

534534
#[test]

tests/test_custom_types.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use pythonize::{
1010
};
1111
use serde_json::{json, Value};
1212

13-
#[pyclass]
13+
#[pyclass(sequence)]
1414
struct CustomList {
1515
items: Vec<PyObject>,
1616
}
@@ -62,6 +62,7 @@ impl PythonizeTypes for PythonizeCustomList {
6262
#[test]
6363
fn test_custom_list() {
6464
Python::with_gil(|py| {
65+
PySequence::register::<CustomList>(py).unwrap();
6566
let serialized = pythonize_custom::<PythonizeCustomList, _>(py, &json!([1, 2, 3]))
6667
.unwrap()
6768
.into_ref(py);
@@ -125,6 +126,7 @@ impl PythonizeTypes for PythonizeCustomDict {
125126
#[test]
126127
fn test_custom_dict() {
127128
Python::with_gil(|py| {
129+
PyMapping::register::<CustomDict>(py).unwrap();
128130
let serialized =
129131
pythonize_custom::<PythonizeCustomDict, _>(py, &json!({ "hello": 1, "world": 2 }))
130132
.unwrap()

0 commit comments

Comments
 (0)