### Eclipse Workspace Patch 1.0 #P py3k Index: Lib/test/test_time.py =================================================================== --- Lib/test/test_time.py (revision 70438) +++ Lib/test/test_time.py (working copy) @@ -115,6 +115,10 @@ except ValueError: self.fail("conversion specifier %r failed with '%s' input." % (format, strf_output)) + + def test_srptime_bytesarg(self): + self.assertRaises(TypeError, time.strptime, b'2009', "%Y") + def test_asctime(self): time.asctime(time.gmtime(self.t)) Index: Lib/_strptime.py =================================================================== --- Lib/_strptime.py (revision 70438) +++ Lib/_strptime.py (working copy) @@ -294,8 +294,14 @@ def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"): """Return a time struct based on the input string and the format string.""" + + if not isinstance(data_string, str): + data_string_type = type(data_string) + raise TypeError("strptime() argument 1 must be str, not %s" % data_string_type) + global _TimeRE_cache, _regex_cache with _cache_lock: + if _getlang() != _TimeRE_cache.locale_time.lang: _TimeRE_cache = TimeRE() _regex_cache.clear()