Make sure time.strptime only accepts strings (and document the fact like
strftime). Already didn't accept bytes but make the check earlier. This also
lifts the limitation of requiring ASCII.
Closes issue #5236. Thanks Tennessee Leeuwenburg.
diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py
index 4c89f03..c2dfaca 100644
--- a/Lib/test/test_time.py
+++ b/Lib/test/test_time.py
@@ -116,6 +116,11 @@
self.fail("conversion specifier %r failed with '%s' input." %
(format, strf_output))
+ def test_strptime_bytes(self):
+ # Make sure only strings are accepted as arguments to strptime.
+ self.assertRaises(TypeError, time.strptime, b'2009', "%Y")
+ self.assertRaises(TypeError, time.strptime, '2009', b'%Y')
+
def test_asctime(self):
time.asctime(time.gmtime(self.t))
self.assertRaises(TypeError, time.asctime, 0)