diff options
author | Brett Cannon <bcannon@gmail.com> | 2009-03-30 21:30:26 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2009-03-30 21:30:26 (GMT) |
commit | 7f6b4f86e305ec63441657c57f5f546d15114ca0 (patch) | |
tree | f7b41eb0be99b61e60e35d9e36746c56ef0a5d7f /Lib/test/test_time.py | |
parent | d687887b536bf1674ac45f78bb77b346aa2b7687 (diff) | |
download | cpython-7f6b4f86e305ec63441657c57f5f546d15114ca0.zip cpython-7f6b4f86e305ec63441657c57f5f546d15114ca0.tar.gz cpython-7f6b4f86e305ec63441657c57f5f546d15114ca0.tar.bz2 |
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.
Diffstat (limited to 'Lib/test/test_time.py')
-rw-r--r-- | Lib/test/test_time.py | 5 |
1 files changed, 5 insertions, 0 deletions
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 @@ class TimeTestCase(unittest.TestCase): 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) |