diff -r ab4432daf69f Lib/_strptime.py --- a/Lib/_strptime.py Mon Oct 22 21:50:27 2012 -0700 +++ b/Lib/_strptime.py Tue Oct 23 15:01:39 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 Tue Oct 23 15:01:39 2012 +0300 @@ -1888,6 +1888,22 @@ with self.assertRaises(ValueError): strptime("-2400", "%z") with self.assertRaises(ValueError): strptime("-000", "%z") + def test_more_strptime(self): + string1 = '2004-12-01 1:2:7.197' + format1 = '%Y-%m-%d %H:%M:%S.%f' + string2 = '201234' + format2 = '%Y%m%d' + string3 = '1234' + format3 = '%H%M%S' + string4 = '123467' + format4 = '%H%M%S' + + with self.assertRaises(ValueError): + self.theclass.strptime(string1, format1) + self.theclass.strptime(string2, format2) + self.theclass.strptime(string3, format3) + self.theclass.strptime(string4, format4) + 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)