[pypy-commit] pypy py3.6: issue #3017 port bpo-29097 from cpython fixing datetime.fromtimestamp for win32

mattip pypy.commits at gmail.com
Wed May 22 11:41:47 EDT 2019


Author: Matti Picus <matti.picus at gmail.com>
Branch: py3.6
Changeset: r96658:194165a1cae6
Date: 2019-05-22 18:40 +0300
http://bitbucket.org/pypy/pypy/changeset/194165a1cae6/

Log:	issue #3017 port bpo-29097 from cpython fixing
	datetime.fromtimestamp for win32

diff --git a/lib-python/3/datetime.py b/lib-python/3/datetime.py
--- a/lib-python/3/datetime.py
+++ b/lib-python/3/datetime.py
@@ -1456,6 +1456,14 @@
             # 23 hours at 1969-09-30 13:00:00 in Kwajalein.
             # Let's probe 24 hours in the past to detect a transition:
             max_fold_seconds = 24 * 3600
+
+            # On Windows localtime_s throws an OSError for negative values,
+            # thus we can't perform fold detection for values of time less
+            # than the max time fold. See comments in _datetimemodule's
+            # version of this method for more details.
+            if t < max_fold_seconds and sys.platform.startswith("win"):
+                return result
+
             y, m, d, hh, mm, ss = converter(t - max_fold_seconds)[:6]
             probe1 = cls(y, m, d, hh, mm, ss, us, tz)
             trans = result - probe1 - timedelta(0, max_fold_seconds)


More information about the pypy-commit mailing list