Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking change handling Arrow Tz (implementing Chrono Tz) in 0.23.4 #4909

Open
kylebarron opened this issue Feb 13, 2025 · 1 comment
Open
Labels

Comments

@kylebarron
Copy link
Contributor

kylebarron commented Feb 13, 2025

Bug Description

This code compiles fine in 0.23.3 but fails to compile in 0.23.4.

`Option<chrono::datetime::DateTime<Tz>>` cannot be converted to a Python object
the following trait bounds were not satisfied:
`Option<chrono::datetime::DateTime<Tz>>: pyo3::IntoPyObject<'_>`
which is required by `Option<chrono::datetime::DateTime<Tz>>: IntoPyObjectExt<'_>`
`&Option<chrono::datetime::DateTime<Tz>>: pyo3::IntoPyObject<'_>`
which is required by `&Option<chrono::datetime::DateTime<Tz>>: IntoPyObjectExt<'_>`
`&mut Option<chrono::datetime::DateTime<Tz>>: pyo3::IntoPyObject<'_>`
which is required by `&mut Option<chrono::datetime::DateTime<Tz>>: IntoPyObjectExt<'_>`
`IntoPyObject` is automatically implemented by the `#[pyclass]` macro
if you do not wish to have a corresponding Python type, implement it manually
if you do not own `Option<chrono::datetime::DateTime<Tz>>` you can perform a manual conversion to one of the types in `pyo3::types::*`

This is an Option<DateTime<Tz>>

This seems to be related to #3266, #4790 (cc @bschoenmaeckers)

Steps to Reproduce

Simplified, this code:

use arrow_array::timezone::Tz;
use chrono::DateTime;
use pyo3::prelude::*;
use pyo3::IntoPyObjectExt;

fn datetime_to_pyobject(py: Python, dt: DateTime<Tz>) -> PyResult<PyObject> {
    dt.into_py_any(py)
}

compiles in 0.23.3 but does not compile in 0.23.4.

Backtrace

Your operating system and version

MacOS 15.3

Your Python version (python --version)

3.11

Your Rust version (rustc --version)

rustc 1.84.0 (9fc6b4312 2025-01-07)

Your PyO3 version

0.23.3/0.23.4

How did you install python? Did you use a virtualenv?

From uv.

Additional Info

No response

@bschoenmaeckers
Copy link
Contributor

Sorry for breaking your usecase. The issue is that arrow_array::timezone::Tz does not implement IntoPyObject which we require now to correctly convert non-fixed-offset timezones. To get the old behaviour you can convert the arrow_array::timezone::Tz timezone to a fixed timezone before converting. e.g. datetime.fixed_offset().into_py_any(py).

I have also created a PR which removes the IntoPyObject constraint on Tz.

@kylebarron kylebarron changed the title Breaking change handling Chrono Tz in 0.23.4 Breaking change handling Arrow Tz (implementing Chrono Tz) in 0.23.4 Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants