summaryrefslogtreecommitdiff
path: root/Lib/test/datetimetester.py
diff options
context:
space:
mode:
authorAmmar Askar <ammar_askar@hotmail.com>2018-07-25 09:54:58 -0700
committerAlexander Belopolsky <abalkin@users.noreply.github.com>2018-07-25 12:54:58 -0400
commit96d1e69a12ed8ab80203277e1abdaf573457a964 (patch)
treee6cdbe9b8eec222ba25cf313c0ba4361f2dd68d9 /Lib/test/datetimetester.py
parent74102c9a5f2327c4fc47feefa072854a53551d1f (diff)
downloadcpython-git-96d1e69a12ed8ab80203277e1abdaf573457a964.tar.gz
bpo-29097: Forego fold detection on windows for low timestamp values (GH-2385)
On Windows, passing a negative value to local results in an OSError because localtime_s on Windows does not support negative timestamps. Unfortunately this means that fold detection for timestamps between 0 and max_fold_seconds will result in this OSError since we subtract max_fold_seconds from the timestamp to detect a fold. However, since we know there haven't been any folds in the interval [0, max_fold_seconds) in any timezone, we can hackily just forego fold detection for this time range on Windows.
Diffstat (limited to 'Lib/test/datetimetester.py')
-rw-r--r--Lib/test/datetimetester.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py
index 7d4cdac9f4..f647a232f4 100644
--- a/Lib/test/datetimetester.py
+++ b/Lib/test/datetimetester.py
@@ -70,7 +70,7 @@ class TestModule(unittest.TestCase):
if not name.startswith('__') and not name.endswith('__'))
allowed = set(['MAXYEAR', 'MINYEAR', 'date', 'datetime',
'datetime_CAPI', 'time', 'timedelta', 'timezone',
- 'tzinfo'])
+ 'tzinfo', 'sys'])
self.assertEqual(names - allowed, set([]))
def test_divide_and_round(self):
@@ -4955,6 +4955,11 @@ class TestLocalTimeDisambiguation(unittest.TestCase):
self.assertEqual(t0.fold, 0)
self.assertEqual(t1.fold, 1)
+ def test_fromtimestamp_low_fold_detection(self):
+ # Ensure that fold detection doesn't cause an
+ # OSError for really low values, see bpo-29097
+ self.assertEqual(datetime.fromtimestamp(0).fold, 0)
+
@support.run_with_tz('EST+05EDT,M3.2.0,M11.1.0')
def test_timestamp(self):
dt0 = datetime(2014, 11, 2, 1, 30)