Skip to content

Commit 0e92991

Browse files
WeepingClown13Ananthu C V
andauthored
bump pyo3 version to 0.25 (#914)
Co-authored-by: Ananthu C V <weepingclown@debian.org>
1 parent 317b4b7 commit 0e92991

File tree

3 files changed

+20
-29
lines changed

3 files changed

+20
-29
lines changed

rust/Cargo.lock

Lines changed: 10 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ strip = true
1414
overflow-checks = false
1515

1616
[dependencies]
17-
pyo3 = { version = "0.24", features = ["extension-module", "generate-import-lib"] }
17+
pyo3 = { version = "0.25", features = ["extension-module", "generate-import-lib"] }
1818

1919
[features]
2020
extension-module = ["pyo3/extension-module"]

rust/src/python/parsing.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ use pyo3::prelude::*;
44
use pyo3::types::PyDate;
55
use pyo3::types::PyDateTime;
66
use pyo3::types::PyTime;
7+
use pyo3::IntoPyObjectExt;
78

89
use crate::parsing::Parser;
910
use crate::python::types::{Duration, FixedTimezone};
1011

11-
// TODO: pyO3 v0.23 deprecates `ToPyObject`, function below must be migrated as per
12-
// https://pyo3.rs/v0.23.0/migration
13-
#[allow(deprecated)]
1412
#[pyfunction]
1513
pub fn parse_iso8601(py: Python, input: &str) -> PyResult<PyObject> {
1614
let parsed = Parser::new(input).parse();
@@ -31,12 +29,12 @@ pub fn parse_iso8601(py: Python, input: &str) -> PyResult<PyObject> {
3129
datetime.microsecond,
3230
Some(
3331
Py::new(py, FixedTimezone::new(offset, datetime.tzname))?
34-
.to_object(py)
32+
.into_any()
3533
.downcast_bound(py)?,
3634
),
3735
)?;
3836

39-
Ok(dt.to_object(py))
37+
Ok(dt.into_any().unbind())
4038
}
4139
None => {
4240
let dt = PyDateTime::new(
@@ -51,7 +49,7 @@ pub fn parse_iso8601(py: Python, input: &str) -> PyResult<PyObject> {
5149
None,
5250
)?;
5351

54-
Ok(dt.to_object(py))
52+
Ok(dt.into_any().unbind())
5553
}
5654
},
5755
(true, false) => {
@@ -62,7 +60,7 @@ pub fn parse_iso8601(py: Python, input: &str) -> PyResult<PyObject> {
6260
datetime.day as u8,
6361
)?;
6462

65-
Ok(dt.to_object(py))
63+
Ok(dt.into_any().unbind())
6664
}
6765
(false, true) => match datetime.offset {
6866
Some(offset) => {
@@ -74,12 +72,12 @@ pub fn parse_iso8601(py: Python, input: &str) -> PyResult<PyObject> {
7472
datetime.microsecond,
7573
Some(
7674
Py::new(py, FixedTimezone::new(offset, datetime.tzname))?
77-
.to_object(py)
75+
.into_any()
7876
.downcast_bound(py)?,
7977
),
8078
)?;
8179

82-
Ok(dt.to_object(py))
80+
Ok(dt.into_any().unbind())
8381
}
8482
None => {
8583
let dt = PyTime::new(
@@ -91,7 +89,7 @@ pub fn parse_iso8601(py: Python, input: &str) -> PyResult<PyObject> {
9189
None,
9290
)?;
9391

94-
Ok(dt.to_object(py))
92+
Ok(dt.into_any().unbind())
9593
}
9694
},
9795
(_, _) => Err(exceptions::PyValueError::new_err(
@@ -111,7 +109,7 @@ pub fn parse_iso8601(py: Python, input: &str) -> PyResult<PyObject> {
111109
Some(duration.microseconds),
112110
),
113111
)?
114-
.to_object(py)),
112+
.into_py_any(py)?),
115113
(_, _, _) => Err(exceptions::PyValueError::new_err(
116114
"Not yet implemented".to_string(),
117115
)),

0 commit comments

Comments
 (0)