Skip to content

Commit 628fd85

Browse files
authored
Bump PyO3 version to 0.27 (#922)
* Bump PyO3 version to 0.27 This will add Python 3.14 support Related to Homebrew/homebrew-core#250674 Signed-off-by: botantony <[email protected]> * rust/src/python: replace deprecated `downcast` method Signed-off-by: botantony <[email protected]> --------- Signed-off-by: botantony <[email protected]>
1 parent 3382956 commit 628fd85

File tree

4 files changed

+24
-25
lines changed

4 files changed

+24
-25
lines changed

rust/Cargo.lock

Lines changed: 10 additions & 11 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.25", features = ["extension-module", "generate-import-lib"] }
17+
pyo3 = { version = "0.27", features = ["extension-module", "generate-import-lib"] }
1818

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

rust/src/python/helpers.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ pub fn get_tz_name<'py>(dt: &Bound<'py, PyAny>) -> PyResult<String> {
100100
}
101101

102102
if let Some(tzname_attr) = tzname_attr {
103-
let tzname: &Bound<PyString> = tzname_attr.downcast()?;
103+
let tzname: &Bound<PyString> = tzname_attr.cast()?;
104104
tzname.extract()
105105
} else {
106106
Ok(String::new())
@@ -118,7 +118,7 @@ pub fn get_offset(dt: &Bound<PyAny>) -> PyResult<i32> {
118118
return Ok(0);
119119
}
120120
let binding = tzinfo.call_method1("utcoffset", (dt,))?;
121-
let offset: &Bound<PyDelta> = binding.downcast()?;
121+
let offset: &Bound<PyDelta> = binding.cast()?;
122122

123123
Ok(offset.get_days() * SECS_PER_DAY as i32 + offset.get_seconds())
124124
}
@@ -161,9 +161,9 @@ pub fn precise_diff<'py>(
161161
let dt1_tz = get_tz_name(dt1)?;
162162
let dt2_tz = get_tz_name(dt2)?;
163163
let mut dtinfo1 = DateTimeInfo {
164-
year: dt1.downcast::<PyDate>()?.get_year(),
165-
month: i32::from(dt1.downcast::<PyDate>()?.get_month()),
166-
day: i32::from(dt1.downcast::<PyDate>()?.get_day()),
164+
year: dt1.cast::<PyDate>()?.get_year(),
165+
month: i32::from(dt1.cast::<PyDate>()?.get_month()),
166+
day: i32::from(dt1.cast::<PyDate>()?.get_day()),
167167
hour: 0,
168168
minute: 0,
169169
second: 0,
@@ -174,9 +174,9 @@ pub fn precise_diff<'py>(
174174
is_datetime: PyDateTime::is_type_of(dt1),
175175
};
176176
let mut dtinfo2 = DateTimeInfo {
177-
year: dt2.downcast::<PyDate>()?.get_year(),
178-
month: i32::from(dt2.downcast::<PyDate>()?.get_month()),
179-
day: i32::from(dt2.downcast::<PyDate>()?.get_day()),
177+
year: dt2.cast::<PyDate>()?.get_year(),
178+
month: i32::from(dt2.cast::<PyDate>()?.get_month()),
179+
day: i32::from(dt2.cast::<PyDate>()?.get_day()),
180180
hour: 0,
181181
minute: 0,
182182
second: 0,
@@ -191,7 +191,7 @@ pub fn precise_diff<'py>(
191191
- helpers::day_number(dtinfo1.year, dtinfo1.month as u8, dtinfo1.day as u8);
192192

193193
if dtinfo1.is_datetime {
194-
let dt1dt: &Bound<PyDateTime> = dt1.downcast()?;
194+
let dt1dt: &Bound<PyDateTime> = dt1.cast()?;
195195

196196
dtinfo1.hour = i32::from(dt1dt.get_hour());
197197
dtinfo1.minute = i32::from(dt1dt.get_minute());
@@ -236,7 +236,7 @@ pub fn precise_diff<'py>(
236236
}
237237

238238
if dtinfo2.is_datetime {
239-
let dt2dt: &Bound<PyDateTime> = dt2.downcast()?;
239+
let dt2dt: &Bound<PyDateTime> = dt2.cast()?;
240240

241241
dtinfo2.hour = i32::from(dt2dt.get_hour());
242242
dtinfo2.minute = i32::from(dt2dt.get_minute());

rust/src/python/parsing.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::parsing::Parser;
1010
use crate::python::types::{Duration, FixedTimezone};
1111

1212
#[pyfunction]
13-
pub fn parse_iso8601(py: Python, input: &str) -> PyResult<PyObject> {
13+
pub fn parse_iso8601(py: Python, input: &str) -> PyResult<Py<PyAny>> {
1414
let parsed = Parser::new(input).parse();
1515

1616
match parsed {
@@ -30,7 +30,7 @@ pub fn parse_iso8601(py: Python, input: &str) -> PyResult<PyObject> {
3030
Some(
3131
Py::new(py, FixedTimezone::new(offset, datetime.tzname))?
3232
.into_any()
33-
.downcast_bound(py)?,
33+
.cast_bound(py)?,
3434
),
3535
)?;
3636

@@ -73,7 +73,7 @@ pub fn parse_iso8601(py: Python, input: &str) -> PyResult<PyObject> {
7373
Some(
7474
Py::new(py, FixedTimezone::new(offset, datetime.tzname))?
7575
.into_any()
76-
.downcast_bound(py)?,
76+
.cast_bound(py)?,
7777
),
7878
)?;
7979

0 commit comments

Comments
 (0)