Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
20 changes: 10 additions & 10 deletions rust/src/python/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pub fn get_tz_name<'py>(dt: &Bound<'py, PyAny>) -> PyResult<String> {
}

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

Ok(offset.get_days() * SECS_PER_DAY as i32 + offset.get_seconds())
}
Expand Down Expand Up @@ -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::<PyDate>()?.get_year(),
month: i32::from(dt1.downcast::<PyDate>()?.get_month()),
day: i32::from(dt1.downcast::<PyDate>()?.get_day()),
year: dt1.cast::<PyDate>()?.get_year(),
month: i32::from(dt1.cast::<PyDate>()?.get_month()),
day: i32::from(dt1.cast::<PyDate>()?.get_day()),
hour: 0,
minute: 0,
second: 0,
Expand All @@ -174,9 +174,9 @@ pub fn precise_diff<'py>(
is_datetime: PyDateTime::is_type_of(dt1),
};
let mut dtinfo2 = DateTimeInfo {
year: dt2.downcast::<PyDate>()?.get_year(),
month: i32::from(dt2.downcast::<PyDate>()?.get_month()),
day: i32::from(dt2.downcast::<PyDate>()?.get_day()),
year: dt2.cast::<PyDate>()?.get_year(),
month: i32::from(dt2.cast::<PyDate>()?.get_month()),
day: i32::from(dt2.cast::<PyDate>()?.get_day()),
hour: 0,
minute: 0,
second: 0,
Expand All @@ -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<PyDateTime> = dt1.downcast()?;
let dt1dt: &Bound<PyDateTime> = dt1.cast()?;

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

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

dtinfo2.hour = i32::from(dt2dt.get_hour());
dtinfo2.minute = i32::from(dt2dt.get_minute());
Expand Down
6 changes: 3 additions & 3 deletions rust/src/python/parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::parsing::Parser;
use crate::python::types::{Duration, FixedTimezone};

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

match parsed {
Expand All @@ -30,7 +30,7 @@ pub fn parse_iso8601(py: Python, input: &str) -> PyResult<PyObject> {
Some(
Py::new(py, FixedTimezone::new(offset, datetime.tzname))?
.into_any()
.downcast_bound(py)?,
.cast_bound(py)?,
),
)?;

Expand Down Expand Up @@ -73,7 +73,7 @@ pub fn parse_iso8601(py: Python, input: &str) -> PyResult<PyObject> {
Some(
Py::new(py, FixedTimezone::new(offset, datetime.tzname))?
.into_any()
.downcast_bound(py)?,
.cast_bound(py)?,
),
)?;

Expand Down