1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
From: Ananthu C V <weepingclown@debian.org>
Date: Mon, 13 Oct 2025 09:03:00 +0100
Subject: pyo3 0.25 compatibility patch
Bug: https://github.com/python-pendulum/pendulum/issues/913
Last-Update: 2025-10-13
---
rust/Cargo.toml | 2 +-
rust/src/python/parsing.rs | 19 +++++++++----------
2 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/rust/Cargo.toml b/rust/Cargo.toml
index e64dfc3..5b66523 100644
--- a/rust/Cargo.toml
+++ b/rust/Cargo.toml
@@ -14,7 +14,7 @@ strip = true
overflow-checks = false
[dependencies]
-pyo3 = { version = ">=0.24,<0.27", features = ["extension-module", "generate-import-lib"] }
+pyo3 = { version = ">=0.24,<0.28", features = ["extension-module"] }
[features]
extension-module = ["pyo3/extension-module"]
diff --git a/rust/src/python/parsing.rs b/rust/src/python/parsing.rs
index 4984c68..c9b8031 100644
--- a/rust/src/python/parsing.rs
+++ b/rust/src/python/parsing.rs
@@ -4,6 +4,7 @@ use pyo3::prelude::*;
use pyo3::types::PyDate;
use pyo3::types::PyDateTime;
use pyo3::types::PyTime;
+use pyo3::conversion::IntoPyObjectExt;
use crate::parsing::Parser;
use crate::python::types::{Duration, FixedTimezone};
@@ -31,12 +32,11 @@ pub fn parse_iso8601(py: Python, input: &str) -> PyResult<PyObject> {
datetime.microsecond,
Some(
Py::new(py, FixedTimezone::new(offset, datetime.tzname))?
- .to_object(py)
- .downcast_bound(py)?,
+ .into_pyobject(py).unwrap().downcast().unwrap()
),
)?;
- Ok(dt.to_object(py))
+ Ok(dt.into_py_any(py).unwrap())
}
None => {
let dt = PyDateTime::new(
@@ -51,7 +51,7 @@ pub fn parse_iso8601(py: Python, input: &str) -> PyResult<PyObject> {
None,
)?;
- Ok(dt.to_object(py))
+ Ok(dt.into_py_any(py).unwrap())
}
},
(true, false) => {
@@ -62,7 +62,7 @@ pub fn parse_iso8601(py: Python, input: &str) -> PyResult<PyObject> {
datetime.day as u8,
)?;
- Ok(dt.to_object(py))
+ Ok(dt.into_py_any(py).unwrap())
}
(false, true) => match datetime.offset {
Some(offset) => {
@@ -74,12 +74,11 @@ pub fn parse_iso8601(py: Python, input: &str) -> PyResult<PyObject> {
datetime.microsecond,
Some(
Py::new(py, FixedTimezone::new(offset, datetime.tzname))?
- .to_object(py)
- .downcast_bound(py)?,
+ .into_pyobject(py).unwrap().downcast().unwrap(),
),
)?;
- Ok(dt.to_object(py))
+ Ok(dt.into_py_any(py).unwrap())
}
None => {
let dt = PyTime::new(
@@ -91,7 +90,7 @@ pub fn parse_iso8601(py: Python, input: &str) -> PyResult<PyObject> {
None,
)?;
- Ok(dt.to_object(py))
+ Ok(dt.into_py_any(py).unwrap())
}
},
(_, _) => Err(exceptions::PyValueError::new_err(
@@ -111,7 +110,7 @@ pub fn parse_iso8601(py: Python, input: &str) -> PyResult<PyObject> {
Some(duration.microseconds),
),
)?
- .to_object(py)),
+ .into_py_any(py).unwrap()),
(_, _, _) => Err(exceptions::PyValueError::new_err(
"Not yet implemented".to_string(),
)),
|