diff -r ab4432daf69f Lib/_strptime.py --- a/Lib/_strptime.py Mon Oct 22 21:50:27 2012 -0700 +++ b/Lib/_strptime.py Wed Oct 24 01:29:49 2012 +0300 @@ -191,15 +191,15 @@ base = super() base.__init__({ # The " \d" part of the regex is to make %c from ANSI C work - 'd': r"(?P3[0-1]|[1-2]\d|0[1-9]|[1-9]| [1-9])", + 'd': r"(?P3[0-1]|[1-2]\d|0[1-9])", 'f': r"(?P[0-9]{1,6})", - 'H': r"(?P2[0-3]|[0-1]\d|\d)", - 'I': r"(?P1[0-2]|0[1-9]|[1-9])", - 'j': r"(?P36[0-6]|3[0-5]\d|[1-2]\d\d|0[1-9]\d|00[1-9]|[1-9]\d|0[1-9]|[1-9])", - 'm': r"(?P1[0-2]|0[1-9]|[1-9])", - 'M': r"(?P[0-5]\d|\d)", - 'S': r"(?P6[0-1]|[0-5]\d|\d)", - 'U': r"(?P5[0-3]|[0-4]\d|\d)", + 'H': r"(?P2[0-3]|[0-1]\d)", + 'I': r"(?P1[0-2]|0[1-9])", + 'j': r"(?P36[0-6]|3[0-5]\d|[1-2]\d\d|0[1-9]\d|00[1-9])", + 'm': r"(?P1[0-2]|0[1-9])", + 'M': r"(?P[0-5]\d)", + 'S': r"(?P6[0-1]|[0-5]\d)", + 'U': r"(?P5[0-3]|[0-4]\d)", 'w': r"(?P[0-6])", # W is set below by using 'U' 'y': r"(?P\d\d)", diff -r ab4432daf69f Lib/test/datetimetester.py --- a/Lib/test/datetimetester.py Mon Oct 22 21:50:27 2012 -0700 +++ b/Lib/test/datetimetester.py Wed Oct 24 01:29:49 2012 +0300 @@ -1888,6 +1888,19 @@ with self.assertRaises(ValueError): strptime("-2400", "%z") with self.assertRaises(ValueError): strptime("-000", "%z") + def test_more_strptime(self): + # append more test cases if needed + test_cases = { + '2004-12-01 1:2:7.197': '%Y-%m-%d %H:%M:%S.%f', + '201234': '%Y%m%d', + '1234': '%H%M%S', + '123467': '%H%M%S' + } + + for string in test_cases: + with self.assertRaises(ValueError): + self.theclass.strptime(string, test_cases[string]) + def test_more_timetuple(self): # This tests fields beyond those tested by the TestDate.test_timetuple. t = self.theclass(2004, 12, 31, 6, 22, 33)