apache / arrow-nanoarrow

Helpers for Arrow C Data & Arrow C Stream interfaces
https://arrow.apache.org/nanoarrow
Apache License 2.0
149 stars 34 forks source link

fix(Python) Use timezone-aware timestamps in some unit tests on Windows #512

Closed aosingh closed 3 weeks ago

aosingh commented 3 weeks ago

Using datetime.timestamp() for timestamps close to EPOCH fails on Windows crashing Python.

Please check this run https://github.com/apache/arrow-nanoarrow/actions/runs/9428246621/job/25973355558

Following snippet

 def test_c_array_timestamp_microseconds():
     d1 = int(round(datetime(1970, 1, 1).timestamp() * 1e6))

raises error

    OSError: [Errno 22] Invalid argument

The crux of the problem is explained in this CPython issue. Solution is to use timezone aware datetime objects