diff -r 6952c14a3f75 Lib/_strptime.py --- a/Lib/_strptime.py Fri Nov 08 21:08:46 2013 +0100 +++ b/Lib/_strptime.py Sun Nov 10 13:07:57 2013 +0200 @@ -329,7 +329,7 @@ (bad_directive, format)) from None # IndexError only occurs when the format string is "%" except IndexError: - raise ValueError("stray %% in format '%s'" % format) + raise ValueError("stray %% in format '%s'" % format) from None _regex_cache[format] = format_regex found = format_regex.match(data_string) if not found: diff -r 6952c14a3f75 Lib/test/test_strptime.py --- a/Lib/test/test_strptime.py Fri Nov 08 21:08:46 2013 +0100 +++ b/Lib/test/test_strptime.py Sun Nov 10 13:07:57 2013 +0200 @@ -224,6 +224,11 @@ _strptime._strptime_time('', '%D') self.assertIs(e.exception.__suppress_context__, True) + # additional check for IndexError branch + with self.assertRaises(ValueError) as e: + _strptime._strptime_time('19', '%Y %') + self.assertIs(e.exception.__suppress_context__, True) + def test_unconverteddata(self): # Check ValueError is raised when there is unconverted data self.assertRaises(ValueError, _strptime._strptime_time, "10 12", "%m")