From 7981f9d2b3ebe8ce9f42ccd058dff0b821b07205 Mon Sep 17 00:00:00 2001 From: botantony Date: Wed, 22 Oct 2025 21:22:28 +0200 Subject: [PATCH 1/2] Bump PyO3 version to 0.27 This will add Python 3.14 support Related to https://github.com/Homebrew/homebrew-core/pull/250674 Signed-off-by: botantony --- rust/Cargo.lock | 21 ++++++++++----------- rust/Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 326301d3..54463e9b 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -74,9 +74,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.25.1" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8970a78afe0628a3e3430376fc5fd76b6b45c4d43360ffd6cdd40bdde72b682a" +checksum = "37a6df7eab65fc7bee654a421404947e10a0f7085b6951bf2ea395f4659fb0cf" dependencies = [ "indoc", "libc", @@ -91,20 +91,19 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.25.1" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "458eb0c55e7ece017adeba38f2248ff3ac615e53660d7c71a238d7d2a01c7598" +checksum = "f77d387774f6f6eec64a004eac0ed525aab7fa1966d94b42f743797b3e395afb" dependencies = [ - "once_cell", "python3-dll-a", "target-lexicon", ] [[package]] name = "pyo3-ffi" -version = "0.25.1" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7114fe5457c61b276ab77c5055f206295b812608083644a5c5b2640c3102565c" +checksum = "2dd13844a4242793e02df3e2ec093f540d948299a6a77ea9ce7afd8623f542be" dependencies = [ "libc", "pyo3-build-config", @@ -112,9 +111,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.25.1" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8725c0a622b374d6cb051d11a0983786448f7785336139c3c94f5aa6bef7e50" +checksum = "eaf8f9f1108270b90d3676b8679586385430e5c0bb78bb5f043f95499c821a71" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -124,9 +123,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.25.1" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4109984c22491085343c05b0dbc54ddc405c3cf7b4374fc533f5c3313a572ccc" +checksum = "70a3b2274450ba5288bc9b8c1b69ff569d1d61189d4bff38f8d22e03d17f932b" dependencies = [ "heck", "proc-macro2", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index d29a4f81..0922472a 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -14,7 +14,7 @@ strip = true overflow-checks = false [dependencies] -pyo3 = { version = "0.25", features = ["extension-module", "generate-import-lib"] } +pyo3 = { version = "0.27", features = ["extension-module", "generate-import-lib"] } [features] extension-module = ["pyo3/extension-module"] From c62ec0051befe69061380d8e5b1c8ffaa52f3f2f Mon Sep 17 00:00:00 2001 From: botantony Date: Fri, 24 Oct 2025 17:15:49 +0200 Subject: [PATCH 2/2] rust/src/python: replace deprecated `downcast` method Signed-off-by: botantony --- rust/src/python/helpers.rs | 20 ++++++++++---------- rust/src/python/parsing.rs | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/rust/src/python/helpers.rs b/rust/src/python/helpers.rs index 037d8c1f..979258a0 100644 --- a/rust/src/python/helpers.rs +++ b/rust/src/python/helpers.rs @@ -100,7 +100,7 @@ pub fn get_tz_name<'py>(dt: &Bound<'py, PyAny>) -> PyResult { } if let Some(tzname_attr) = tzname_attr { - let tzname: &Bound = tzname_attr.downcast()?; + let tzname: &Bound = tzname_attr.cast()?; tzname.extract() } else { Ok(String::new()) @@ -118,7 +118,7 @@ pub fn get_offset(dt: &Bound) -> PyResult { return Ok(0); } let binding = tzinfo.call_method1("utcoffset", (dt,))?; - let offset: &Bound = binding.downcast()?; + let offset: &Bound = binding.cast()?; Ok(offset.get_days() * SECS_PER_DAY as i32 + offset.get_seconds()) } @@ -161,9 +161,9 @@ pub fn precise_diff<'py>( let dt1_tz = get_tz_name(dt1)?; let dt2_tz = get_tz_name(dt2)?; let mut dtinfo1 = DateTimeInfo { - year: dt1.downcast::()?.get_year(), - month: i32::from(dt1.downcast::()?.get_month()), - day: i32::from(dt1.downcast::()?.get_day()), + year: dt1.cast::()?.get_year(), + month: i32::from(dt1.cast::()?.get_month()), + day: i32::from(dt1.cast::()?.get_day()), hour: 0, minute: 0, second: 0, @@ -174,9 +174,9 @@ pub fn precise_diff<'py>( is_datetime: PyDateTime::is_type_of(dt1), }; let mut dtinfo2 = DateTimeInfo { - year: dt2.downcast::()?.get_year(), - month: i32::from(dt2.downcast::()?.get_month()), - day: i32::from(dt2.downcast::()?.get_day()), + year: dt2.cast::()?.get_year(), + month: i32::from(dt2.cast::()?.get_month()), + day: i32::from(dt2.cast::()?.get_day()), hour: 0, minute: 0, second: 0, @@ -191,7 +191,7 @@ pub fn precise_diff<'py>( - helpers::day_number(dtinfo1.year, dtinfo1.month as u8, dtinfo1.day as u8); if dtinfo1.is_datetime { - let dt1dt: &Bound = dt1.downcast()?; + let dt1dt: &Bound = dt1.cast()?; dtinfo1.hour = i32::from(dt1dt.get_hour()); dtinfo1.minute = i32::from(dt1dt.get_minute()); @@ -236,7 +236,7 @@ pub fn precise_diff<'py>( } if dtinfo2.is_datetime { - let dt2dt: &Bound = dt2.downcast()?; + let dt2dt: &Bound = dt2.cast()?; dtinfo2.hour = i32::from(dt2dt.get_hour()); dtinfo2.minute = i32::from(dt2dt.get_minute()); diff --git a/rust/src/python/parsing.rs b/rust/src/python/parsing.rs index 85916757..90fc275c 100644 --- a/rust/src/python/parsing.rs +++ b/rust/src/python/parsing.rs @@ -10,7 +10,7 @@ use crate::parsing::Parser; use crate::python::types::{Duration, FixedTimezone}; #[pyfunction] -pub fn parse_iso8601(py: Python, input: &str) -> PyResult { +pub fn parse_iso8601(py: Python, input: &str) -> PyResult> { let parsed = Parser::new(input).parse(); match parsed { @@ -30,7 +30,7 @@ pub fn parse_iso8601(py: Python, input: &str) -> PyResult { Some( Py::new(py, FixedTimezone::new(offset, datetime.tzname))? .into_any() - .downcast_bound(py)?, + .cast_bound(py)?, ), )?; @@ -73,7 +73,7 @@ pub fn parse_iso8601(py: Python, input: &str) -> PyResult { Some( Py::new(py, FixedTimezone::new(offset, datetime.tzname))? .into_any() - .downcast_bound(py)?, + .cast_bound(py)?, ), )?;