Skip to content

Conversation

@littlebutt
Copy link
Contributor

@littlebutt littlebutt commented Jul 24, 2023

  • Fix _datetimemodule.c when calling datetime.datetime.fromtimestamp(0).astimezone() with OSError on Windows

@yabirgb
Copy link

yabirgb commented Jan 2, 2024

Hello! Bumping the PR in case someone can take a look

else
u2 = u1 - max_fold_seconds;
#ifdef MS_WINDOWS
u2 += max_fold_seconds;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we only want to do this if it's too small? Otherwise it has the potential to do the conversion wrong if you put in a "normal" time that's within max_fold_seconds of an offset change (either DST or legal change). We probably assume that none of these happened on the first day after epoch.

Otherwise, this seems like a fine way to handle it. A "real" fix would be much more complex, and probably inconsistent with actual timezone aware datetimes, which I'm sure are the preferred approach these days.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @zooba. See the Windows-specific comment in datetime_from_timet_and_us().

Also this change needs tests.

else
u2 = u1 - max_fold_seconds;
#ifdef MS_WINDOWS
u2 += max_fold_seconds;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @zooba. See the Windows-specific comment in datetime_from_timet_and_us().

Also this change needs tests.

@bedevere-app
Copy link

bedevere-app bot commented Feb 1, 2024

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@vstinner
Copy link
Member

I merged #143463 instead. Thanks for your contribution anyway ;-)

@vstinner vstinner closed this Jan 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants