From 9d6d9287693032b869909bfe8dd07a8341749dd9 Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Fri, 7 Nov 2025 21:50:18 +0000 Subject: [PATCH 1/3] ci: extend test matrix to 3.14, more arm runners (#98) --- .github/workflows/ci.yml | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6c08531..3d69440 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,17 +49,21 @@ jobs: strategy: fail-fast: false # If one platform fails, allow the rest to keep testing. matrix: - python-architecture: ["x64"] - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.13t"] - os: ["macos-13", "ubuntu-latest", "windows-latest"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14", "3.14t"] + os: ["macos-latest", "ubuntu-latest", "windows-latest"] rust: [stable] include: - - python-version: "3.13" + - python-version: "3.14" os: "ubuntu-latest" rust: ${{ needs.resolve.outputs.MSRV }} - - python-version: "3.13" - python-architecture: "arm64" - os: "macos-latest" + - python-version: "3.14" + os: "macos-15-intel" + rust: "stable" + - python-version: "3.14" + os: "ubuntu-24.04-arm" + rust: "stable" + - python-version: "3.14" + os: "windows-11-arm" rust: "stable" steps: @@ -69,7 +73,6 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - architecture: ${{ matrix.python-python-architecture }} - name: Install Rust toolchain uses: dtolnay/rust-toolchain@master @@ -88,9 +91,7 @@ jobs: - name: Test run: cargo test --verbose - # https://github.com/PyO3/pyo3/issues/4709 - can't use abi3 w. freethreaded build - - if: ${{ !endsWith(matrix.python-version, 't') }} - name: Test (abi3) + - name: Test (abi3) run: cargo test --verbose --features pyo3/abi3-py37 env: From 89420b2d91721f277f073befa70a95016606e9ed Mon Sep 17 00:00:00 2001 From: Tino Wagner Date: Fri, 7 Nov 2025 22:50:36 +0100 Subject: [PATCH 2/3] Bump PyO3 to 0.27 (#96) * Bump PyO3 to 0.27 Update pyo3 dependency to 0.27. Replace deprecated DowncastError with CastError. --------- Co-authored-by: David Hewitt --- Cargo.toml | 4 ++-- src/error.rs | 14 +++++++------- tests/test_with_serde_path_to_err.rs | 11 +++++++---- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c0797e7..ce406ad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,11 +13,11 @@ documentation = "https://docs.rs/crate/pythonize/" [dependencies] serde = { version = "1.0", default-features = false, features = ["std"] } -pyo3 = { version = "0.26", default-features = false } +pyo3 = { version = "0.27", default-features = false } [dev-dependencies] serde = { version = "1.0", default-features = false, features = ["derive"] } -pyo3 = { version = "0.26", default-features = false, features = ["auto-initialize", "macros", "py-clone"] } +pyo3 = { version = "0.27", default-features = false, features = ["auto-initialize", "macros", "py-clone"] } serde_json = "1.0" serde_bytes = "0.11" maplit = "1.0.2" diff --git a/src/error.rs b/src/error.rs index 7828a71..b608106 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,5 +1,5 @@ use pyo3::PyErr; -use pyo3::{exceptions::*, DowncastError, DowncastIntoError}; +use pyo3::{exceptions::*, CastError, CastIntoError}; use serde::{de, ser}; use std::convert::Infallible; use std::error; @@ -153,18 +153,18 @@ impl From for PythonizeError { } } -/// Handle errors that occur when attempting to use `PyAny::cast_as` -impl<'a, 'py> From> for PythonizeError { - fn from(other: DowncastError<'a, 'py>) -> Self { +/// Handle errors that occur when attempting to use `PyAny::cast` +impl<'a, 'py> From> for PythonizeError { + fn from(other: CastError<'a, 'py>) -> Self { Self { inner: Box::new(ErrorImpl::UnexpectedType(other.to_string())), } } } -/// Handle errors that occur when attempting to use `PyAny::cast_as` -impl<'py> From> for PythonizeError { - fn from(other: DowncastIntoError<'py>) -> Self { +/// Handle errors that occur when attempting to use `PyAny::cast` +impl<'py> From> for PythonizeError { + fn from(other: CastIntoError<'py>) -> Self { Self { inner: Box::new(ErrorImpl::UnexpectedType(other.to_string())), } diff --git a/tests/test_with_serde_path_to_err.rs b/tests/test_with_serde_path_to_err.rs index d92c4d1..82fd8bb 100644 --- a/tests/test_with_serde_path_to_err.rs +++ b/tests/test_with_serde_path_to_err.rs @@ -100,7 +100,10 @@ fn test_de_invalid() { let err = serde_path_to_error::deserialize::<_, Root>(de).unwrap_err(); assert_eq!(err.path().to_string(), "root_map.nested_1.nested_key"); - assert_eq!(err.to_string(), "root_map.nested_1.nested_key: unexpected type: 'int' object cannot be converted to 'PyString'"); + assert_eq!( + err.to_string(), + "root_map.nested_1.nested_key: unexpected type: 'int' object cannot be cast as 'str'" + ); }) } @@ -143,7 +146,7 @@ fn test_ser_valid() { .get_item("root_map") .unwrap() .unwrap() - .downcast_into::() + .cast_into::() .unwrap(); assert_eq!(root_map.len(), 2); @@ -151,7 +154,7 @@ fn test_ser_valid() { .get_item("nested_0") .unwrap() .unwrap() - .downcast_into::() + .cast_into::() .unwrap(); assert_eq!(nested_0.len(), 1); let nested_key_0: String = nested_0 @@ -166,7 +169,7 @@ fn test_ser_valid() { .get_item("nested_1") .unwrap() .unwrap() - .downcast_into::() + .cast_into::() .unwrap(); assert_eq!(nested_1.len(), 1); let nested_key_1: String = nested_1 From 43c714f13d40db35b080659c67b818758cc8c202 Mon Sep 17 00:00:00 2001 From: David Hewitt Date: Fri, 7 Nov 2025 21:57:31 +0000 Subject: [PATCH 3/3] release: 0.27.0 (#99) --- CHANGELOG.md | 3 +++ Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a21bd55..f267740 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.27.0 - 2025-11-07 +- Update to PyO3 0.27 + ## 0.26.0 - 2025-08-30 ### Packaging diff --git a/Cargo.toml b/Cargo.toml index ce406ad..4a714a3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pythonize" -version = "0.26.0" +version = "0.27.0" authors = ["David Hewitt <1939362+davidhewitt@users.noreply.github.com>"] edition = "2021" rust-version = "1.74"