summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2012-01-26 23:08:48 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2012-01-26 23:08:48 (GMT)
commitc1b5d34ede2701cf45f35cf52d33d8dca5059ec6 (patch)
treeeb986539565614701c5fee77b6c69746e68790fc /Lib
parentc9e7ef7d70f531864ffef222ff72ccf75a9425c5 (diff)
downloadcpython-c1b5d34ede2701cf45f35cf52d33d8dca5059ec6.zip
cpython-c1b5d34ede2701cf45f35cf52d33d8dca5059ec6.tar.gz
cpython-c1b5d34ede2701cf45f35cf52d33d8dca5059ec6.tar.bz2
Issue #13847: time.localtime() and time.gmtime() now raise an OSError instead
of ValueError on failure. time.ctime() and time.asctime() now raises an OSError if localtime() failed.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_time.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py
index 685e821..0533895 100644
--- a/Lib/test/test_time.py
+++ b/Lib/test/test_time.py
@@ -343,6 +343,21 @@ class TimeTestCase(unittest.TestCase):
dt = t2 - t1
self.assertAlmostEqual(dt, 0.1, delta=0.2)
+ def test_localtime_failure(self):
+ # Issue #13847: check for localtime() failure
+ invalid_time_t = 2**60
+ try:
+ time.localtime(invalid_time_t)
+ except ValueError as err:
+ if str(err) == "timestamp out of range for platform time_t":
+ self.skipTest("need 64-bit time_t")
+ else:
+ raise
+ except OSError:
+ pass
+ self.assertRaises(OSError, time.localtime, invalid_time_t)
+ self.assertRaises(OSError, time.gmtime, invalid_time_t)
+ self.assertRaises(OSError, time.ctime, invalid_time_t)
class TestLocale(unittest.TestCase):
def setUp(self):