LouisLou2 opened a new pull request, #2209: URL: https://github.com/apache/fury/pull/2209
<!-- **Thanks for contributing to Fury.** **If this is your first time opening a PR on fury, you can refer to [CONTRIBUTING.md](https://github.com/apache/fury/blob/main/CONTRIBUTING.md).** Contribution Checklist - The **Apache Fury (incubating)** community has restrictions on the naming of pr titles. You can also find instructions in [CONTRIBUTING.md](https://github.com/apache/fury/blob/main/CONTRIBUTING.md). - Fury has a strong focus on performance. If the PR you submit will have an impact on performance, please benchmark it first and provide the benchmark result here. --> ## What does this PR do? This PR resolves an `OSError: [Errno 22] Invalid argument` in `TimestampSerializer` on Windows when serializing naive `datetime` objects (no `tzinfo`) close to the Unix epoch. This issue stems from `datetime.datetime.timestamp()` failing for such dates on Windows. The fix applies a workaround for Windows when handling naive `datetime` objects: 1. The naive `datetime` is made timezone-aware by setting its `tzinfo` to `datetime.timezone.utc`. 2. The POSIX timestamp is then retrieved. 3. This timestamp is adjusted by the local timezone offset (considering DST) to produce the correct microsecond timestamp for serialization. This approach ensures correct timestamp generation on Windows for these edge cases without affecting other platforms or timezone-aware `datetime` objects. The fix is implemented in both `_serialization.pyx` and `_serializer.py`. ## Related issues - #2118 ## Does this PR introduce any user-facing change? <!-- If any user-facing interface changes, please [open an issue](https://github.com/apache/fury/issues/new/choose) describing the need to do so and update the document if necessary. --> - [ ] Does this PR introduce any public API change? - [ ] Does this PR introduce any binary protocol compatibility change? ## Benchmark <!-- When the PR has an impact on performance (if you don't know whether the PR will have an impact on performance, you can submit the PR first, and if it will have impact on performance, the code reviewer will explain it), be sure to attach a benchmark data here. --> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
