Skip to content

Commit d22654a

Browse files
Update pyo3 to 0.28.0. (#104)
* Update `pyo3` to 0.28.0. * fixup, bump MSRV to 1.83 --------- Co-authored-by: David Hewitt <mail@davidhewitt.dev>
1 parent 43c714f commit d22654a

5 files changed

Lines changed: 32 additions & 30 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## Unreleased
2+
3+
- Bump MSRV to 1.83.
4+
- Update `pyo3` to 0.28.
5+
16
## 0.27.0 - 2025-11-07
27
- Update to PyO3 0.27
38

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "pythonize"
33
version = "0.27.0"
44
authors = ["David Hewitt <1939362+davidhewitt@users.noreply.github.com>"]
55
edition = "2021"
6-
rust-version = "1.74"
6+
rust-version = "1.83"
77
license = "MIT"
88
description = "Serde Serializer & Deserializer from Rust <--> Python, backed by PyO3."
99
homepage = "https://github.com/davidhewitt/pythonize"
@@ -13,11 +13,11 @@ documentation = "https://docs.rs/crate/pythonize/"
1313

1414
[dependencies]
1515
serde = { version = "1.0", default-features = false, features = ["std"] }
16-
pyo3 = { version = "0.27", default-features = false }
16+
pyo3 = { version = "0.28", default-features = false }
1717

1818
[dev-dependencies]
1919
serde = { version = "1.0", default-features = false, features = ["derive"] }
20-
pyo3 = { version = "0.27", default-features = false, features = ["auto-initialize", "macros", "py-clone"] }
20+
pyo3 = { version = "0.28", default-features = false, features = ["auto-initialize", "macros", "py-clone"] }
2121
serde_json = "1.0"
2222
serde_bytes = "0.11"
2323
maplit = "1.0.2"

src/de.rs

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,6 @@ mod test {
520520
use super::*;
521521
use crate::error::ErrorImpl;
522522
use maplit::hashmap;
523-
use pyo3::ffi::c_str;
524523
use pyo3::{IntoPyObject, Python};
525524
use serde_json::{json, Value as JsonValue};
526525

@@ -545,7 +544,7 @@ mod test {
545544

546545
let expected = Empty;
547546
let expected_json = json!(null);
548-
let code = c_str!("None");
547+
let code = c"None";
549548
test_de(code, &expected, &expected_json);
550549
}
551550

@@ -571,7 +570,7 @@ mod test {
571570
"baz": 45.23,
572571
"qux": true
573572
});
574-
let code = c_str!("{'foo': 'Foo', 'bar': 8, 'baz': 45.23, 'qux': True}");
573+
let code = c"{'foo': 'Foo', 'bar': 8, 'baz': 45.23, 'qux': True}";
575574
test_de(code, &expected, &expected_json);
576575
}
577576

@@ -583,7 +582,7 @@ mod test {
583582
bar: usize,
584583
}
585584

586-
let code = c_str!("{'foo': 'Foo'}");
585+
let code = c"{'foo': 'Foo'}";
587586

588587
Python::attach(|py| {
589588
let locals = PyDict::new(py);
@@ -602,7 +601,7 @@ mod test {
602601

603602
let expected = TupleStruct("cat".to_string(), -10.05);
604603
let expected_json = json!(["cat", -10.05]);
605-
let code = c_str!("('cat', -10.05)");
604+
let code = c"('cat', -10.05)";
606605
test_de(code, &expected, &expected_json);
607606
}
608607

@@ -611,7 +610,7 @@ mod test {
611610
#[derive(Debug, Deserialize, PartialEq)]
612611
struct TupleStruct(String, f64);
613612

614-
let code = c_str!("('cat', -10.05, 'foo')");
613+
let code = c"('cat', -10.05, 'foo')";
615614

616615
Python::attach(|py| {
617616
let locals = PyDict::new(py);
@@ -630,63 +629,63 @@ mod test {
630629

631630
let expected = TupleStruct("cat".to_string(), -10.05);
632631
let expected_json = json!(["cat", -10.05]);
633-
let code = c_str!("['cat', -10.05]");
632+
let code = c"['cat', -10.05]";
634633
test_de(code, &expected, &expected_json);
635634
}
636635

637636
#[test]
638637
fn test_tuple() {
639638
let expected = ("foo".to_string(), 5);
640639
let expected_json = json!(["foo", 5]);
641-
let code = c_str!("('foo', 5)");
640+
let code = c"('foo', 5)";
642641
test_de(code, &expected, &expected_json);
643642
}
644643

645644
#[test]
646645
fn test_tuple_from_pylist() {
647646
let expected = ("foo".to_string(), 5);
648647
let expected_json = json!(["foo", 5]);
649-
let code = c_str!("['foo', 5]");
648+
let code = c"['foo', 5]";
650649
test_de(code, &expected, &expected_json);
651650
}
652651

653652
#[test]
654653
fn test_vec_from_pyset() {
655654
let expected = vec!["foo".to_string()];
656655
let expected_json = json!(["foo"]);
657-
let code = c_str!("{'foo'}");
656+
let code = c"{'foo'}";
658657
test_de(code, &expected, &expected_json);
659658
}
660659

661660
#[test]
662661
fn test_vec_from_pyfrozenset() {
663662
let expected = vec!["foo".to_string()];
664663
let expected_json = json!(["foo"]);
665-
let code = c_str!("frozenset({'foo'})");
664+
let code = c"frozenset({'foo'})";
666665
test_de(code, &expected, &expected_json);
667666
}
668667

669668
#[test]
670669
fn test_vec() {
671670
let expected = vec![3, 2, 1];
672671
let expected_json = json!([3, 2, 1]);
673-
let code = c_str!("[3, 2, 1]");
672+
let code = c"[3, 2, 1]";
674673
test_de(code, &expected, &expected_json);
675674
}
676675

677676
#[test]
678677
fn test_vec_from_tuple() {
679678
let expected = vec![3, 2, 1];
680679
let expected_json = json!([3, 2, 1]);
681-
let code = c_str!("(3, 2, 1)");
680+
let code = c"(3, 2, 1)";
682681
test_de(code, &expected, &expected_json);
683682
}
684683

685684
#[test]
686685
fn test_hashmap() {
687686
let expected = hashmap! {"foo".to_string() => 4};
688687
let expected_json = json!({"foo": 4 });
689-
let code = c_str!("{'foo': 4}");
688+
let code = c"{'foo': 4}";
690689
test_de(code, &expected, &expected_json);
691690
}
692691

@@ -699,7 +698,7 @@ mod test {
699698

700699
let expected = Foo::Variant;
701700
let expected_json = json!("Variant");
702-
let code = c_str!("'Variant'");
701+
let code = c"'Variant'";
703702
test_de(code, &expected, &expected_json);
704703
}
705704

@@ -712,7 +711,7 @@ mod test {
712711

713712
let expected = Foo::Tuple(12, "cat".to_string());
714713
let expected_json = json!({"Tuple": [12, "cat"]});
715-
let code = c_str!("{'Tuple': [12, 'cat']}");
714+
let code = c"{'Tuple': [12, 'cat']}";
716715
test_de(code, &expected, &expected_json);
717716
}
718717

@@ -725,7 +724,7 @@ mod test {
725724

726725
let expected = Foo::NewType("cat".to_string());
727726
let expected_json = json!({"NewType": "cat" });
728-
let code = c_str!("{'NewType': 'cat'}");
727+
let code = c"{'NewType': 'cat'}";
729728
test_de(code, &expected, &expected_json);
730729
}
731730

@@ -741,7 +740,7 @@ mod test {
741740
bar: 25,
742741
};
743742
let expected_json = json!({"Struct": {"foo": "cat", "bar": 25 }});
744-
let code = c_str!("{'Struct': {'foo': 'cat', 'bar': 25}}");
743+
let code = c"{'Struct': {'foo': 'cat', 'bar': 25}}";
745744
test_de(code, &expected, &expected_json);
746745
}
747746
#[test]
@@ -754,7 +753,7 @@ mod test {
754753

755754
let expected = Foo::Tuple(12.0, 'c');
756755
let expected_json = json!([12.0, 'c']);
757-
let code = c_str!("[12.0, 'c']");
756+
let code = c"[12.0, 'c']";
758757
test_de(code, &expected, &expected_json);
759758
}
760759

@@ -768,7 +767,7 @@ mod test {
768767

769768
let expected = Foo::NewType("cat".to_string());
770769
let expected_json = json!("cat");
771-
let code = c_str!("'cat'");
770+
let code = c"'cat'";
772771
test_de(code, &expected, &expected_json);
773772
}
774773

@@ -785,7 +784,7 @@ mod test {
785784
bar: [2, 5, 3, 1],
786785
};
787786
let expected_json = json!({"foo": ["a", "b", "c"], "bar": [2, 5, 3, 1]});
788-
let code = c_str!("{'foo': ['a', 'b', 'c'], 'bar': [2, 5, 3, 1]}");
787+
let code = c"{'foo': ['a', 'b', 'c'], 'bar': [2, 5, 3, 1]}";
789788
test_de(code, &expected, &expected_json);
790789
}
791790

@@ -818,8 +817,7 @@ mod test {
818817
};
819818
let expected_json =
820819
json!({"name": "SomeFoo", "bar": { "value": 13, "variant": { "Tuple": [-1.5, 8]}}});
821-
let code =
822-
c_str!("{'name': 'SomeFoo', 'bar': {'value': 13, 'variant': {'Tuple': [-1.5, 8]}}}");
820+
let code = c"{'name': 'SomeFoo', 'bar': {'value': 13, 'variant': {'Tuple': [-1.5, 8]}}}";
823821
test_de(code, &expected, &expected_json);
824822
}
825823

@@ -868,7 +866,7 @@ mod test {
868866
fn test_char() {
869867
let expected = 'a';
870868
let expected_json = json!("a");
871-
let code = c_str!("'a'");
869+
let code = c"'a'";
872870
test_de(code, &expected, &expected_json);
873871
}
874872

src/ser.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,6 @@ impl<'py, P: PythonizeTypes> ser::SerializeStructVariant for PythonStructVariant
622622
mod test {
623623
use super::pythonize;
624624
use maplit::hashmap;
625-
use pyo3::ffi::c_str;
626625
use pyo3::prelude::*;
627626
use pyo3::pybacked::PyBackedStr;
628627
use pyo3::types::{PyBytes, PyDict};
@@ -639,7 +638,7 @@ mod test {
639638
locals.set_item("obj", obj)?;
640639

641640
py.run(
642-
c_str!("import json; result = json.dumps(obj, separators=(',', ':'))"),
641+
c"import json; result = json.dumps(obj, separators=(',', ':'))",
643642
None,
644643
Some(&locals),
645644
)?;

tests/test_with_serde_path_to_err.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ fn test_de_invalid() {
102102
assert_eq!(err.path().to_string(), "root_map.nested_1.nested_key");
103103
assert_eq!(
104104
err.to_string(),
105-
"root_map.nested_1.nested_key: unexpected type: 'int' object cannot be cast as 'str'"
105+
"root_map.nested_1.nested_key: unexpected type: 'int' object is not an instance of 'str'"
106106
);
107107
})
108108
}

0 commit comments

Comments
 (0)