]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue13674 Correct crash with strftime %y format under Windows
authorTim Golden <mail@timgolden.me.uk>
Tue, 12 Nov 2013 12:48:20 +0000 (12:48 +0000)
committerTim Golden <mail@timgolden.me.uk>
Tue, 12 Nov 2013 12:48:20 +0000 (12:48 +0000)
1  2 
Lib/test/test_strftime.py
Modules/timemodule.c

index 6510c3669803dcb2263aa3417aa9d09b283506ef,78c9c5bdb92555518aa9ad48c8ab5f009ca91993..d3f80c6631ff8ca448657b3b8f31724761e0b945
@@@ -177,5 -177,31 +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):
+             time.strftime("%y", (1899, 1, 1, 0, 0, 0, 0, 0, 0))
+     @unittest.skipIf(sys.platform == "win32", "Doesn't apply on Windows")
+     def test_y_before_1900_nonwin(self):
+         self.assertEquals(
+             time.strftime("%y", (1899, 1, 1, 0, 0, 0, 0, 0, 0)), "99")
+     def test_y_1900(self):
+         self.assertEquals(
+             time.strftime("%y", (1900, 1, 1, 0, 0, 0, 0, 0, 0)), "00")
+     def test_y_after_1900(self):
+         self.assertEquals(
+             time.strftime("%y", (2013, 1, 1, 0, 0, 0, 0, 0, 0)), "13")
+ def test_main():
+     support.run_unittest(StrftimeTest, Y1900Tests)
  if __name__ == '__main__':
 -    test_main()
 +    unittest.main()
Simple merge