From 623902df7cdfe64dd1f7b6c5ce4a715ee745b4b9 Mon Sep 17 00:00:00 2001 From: littlebutt Date: Mon, 24 Jul 2023 21:27:15 +0800 Subject: [PATCH 1/2] gh-107078: fix `astimezone` on Windows --- Modules/_datetimemodule.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c index b8cb0c012fd537..18842b379ca1a7 100644 --- a/Modules/_datetimemodule.c +++ b/Modules/_datetimemodule.c @@ -6333,9 +6333,18 @@ local_to_seconds(int year, int month, int day, u2 = u1 + max_fold_seconds; else u2 = u1 - max_fold_seconds; +#ifdef MS_WINDOWS + u2 += max_fold_seconds; +#endif + lt = local(u2); if (lt == -1) return -1; +#ifdef MS_WINDOWS + u2 -= max_fold_seconds; + lt -= max_fold_seconds; +#endif + b = lt - u2; if (a == b) return u1; From fa97af35d18f5eae1a240409bc9f520d54708f42 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Mon, 24 Jul 2023 13:35:23 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Windows/2023-07-24-13-35-22.gh-issue-107078.leZSPg.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Windows/2023-07-24-13-35-22.gh-issue-107078.leZSPg.rst diff --git a/Misc/NEWS.d/next/Windows/2023-07-24-13-35-22.gh-issue-107078.leZSPg.rst b/Misc/NEWS.d/next/Windows/2023-07-24-13-35-22.gh-issue-107078.leZSPg.rst new file mode 100644 index 00000000000000..82089f61a01aa2 --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2023-07-24-13-35-22.gh-issue-107078.leZSPg.rst @@ -0,0 +1 @@ +Fix `_datetimemodule.c` when calling `datetime.datetime.fromtimestamp(0).astimezone()` with `OSError` on Windows