cpython: 41a4c55db7f2 (original) (raw)
--- a/Lib/test/test_strftime.py +++ b/Lib/test/test_strftime.py @@ -177,5 +177,31 @@ class StrftimeTest(unittest.TestCase): print(" Expected %s, but got %s" % (e[1], result)) +class Y1900Tests(unittest.TestCase):
- """A limitation of the MS C runtime library is that it crashes if
- a date before 1900 is passed with a format string containing "%y"
- """
- @unittest.skipUnless(sys.platform == "win32", "Only applies to Windows")
- def test_y_before_1900_win(self):
with self.assertRaises(ValueError):[](#l1.14)
time.strftime("%y", (1899, 1, 1, 0, 0, 0, 0, 0, 0))[](#l1.15)
- @unittest.skipIf(sys.platform == "win32", "Doesn't apply on Windows")
- def test_y_before_1900_nonwin(self):
self.assertEquals([](#l1.19)
time.strftime("%y", (1899, 1, 1, 0, 0, 0, 0, 0, 0)), "99")[](#l1.20)
- def test_y_1900(self):
self.assertEquals([](#l1.23)
time.strftime("%y", (1900, 1, 1, 0, 0, 0, 0, 0, 0)), "00")[](#l1.24)
- def test_y_after_1900(self):
self.assertEquals([](#l1.27)
time.strftime("%y", (2013, 1, 1, 0, 0, 0, 0, 0, 0)), "13")[](#l1.28)
+ if name == 'main': unittest.main()
--- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -642,6 +642,13 @@ time_strftime(PyObject *self, PyObject * Py_DECREF(format); return NULL; }