diff options
author | Armin Rigo <arigo@tunes.org> | 2005-11-07 07:15:48 +0000 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2005-11-07 07:15:48 +0000 |
commit | 92f1be399b21cba12bbfdaf4baa5ecd325e8c2be (patch) | |
tree | 15dce0bc55ae66b981338488bdf11124f74ab599 /Lib/test | |
parent | a65f2ba9c9a3fa335232c7f5d3b11023e58f2d59 (diff) | |
download | cpython-92f1be399b21cba12bbfdaf4baa5ecd325e8c2be.tar.gz |
similar to SF bug 847019: a quick check in the time() constructor, which
accepts strings only for unpickling reasons. This check prevents the honest
mistake of passing a string like '2:59.0' to time() and getting an insane
object.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_datetime.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_datetime.py b/Lib/test/test_datetime.py index 9abfb875b9..27f42c6790 100644 --- a/Lib/test/test_datetime.py +++ b/Lib/test/test_datetime.py @@ -1830,6 +1830,13 @@ class TestTime(HarmlessMixedComparison): self.assertEqual(dt1.isoformat(), dt2.isoformat()) self.assertEqual(dt2.newmeth(-7), dt1.hour + dt1.second - 7) + def test_backdoor_resistance(self): + # see TestDate.test_backdoor_resistance(). + base = '2:59.0' + for hour_byte in ' ', '9', chr(24), '\xff': + self.assertRaises(TypeError, self.theclass, + hour_byte + base[1:]) + # A mixin for classes with a tzinfo= argument. Subclasses must define # theclass as a class atribute, and theclass(1, 1, 1, tzinfo=whatever) # must be legit (which is true for time and datetime). |