summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2006-03-20 01:58:39 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2006-03-20 01:58:39 (GMT)
commitd5b0c9b87edca68cd31ed61d0c143d9d4160c109 (patch)
treedff07863a4dc07c8ec6b14f5f92b0878ca0d022f /Lib/test
parent29892cc3862cfa5f343dbacb410edadf02fcce9d (diff)
downloadcpython-d5b0c9b87edca68cd31ed61d0c143d9d4160c109.zip
cpython-d5b0c9b87edca68cd31ed61d0c143d9d4160c109.tar.gz
cpython-d5b0c9b87edca68cd31ed61d0c143d9d4160c109.tar.bz2
Fix problem spotted by Coverity that occurs if tzinfo.tzname().replace()
returns a non-string when converting %Z. Will backport.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_datetime.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_datetime.py b/Lib/test/test_datetime.py
index 27f42c6..2528b4a 100644
--- a/Lib/test/test_datetime.py
+++ b/Lib/test/test_datetime.py
@@ -1168,6 +1168,17 @@ class TestDateTime(TestDate):
self.assertEqual(dt2 - dt1, us)
self.assert_(dt1 < dt2)
+ def test_strftime_with_bad_tzname_replace(self):
+ # verify ok if tzinfo.tzname().replace() returns a non-string
+ class MyTzInfo(FixedOffset):
+ def tzname(self, dt):
+ class MyStr(str):
+ def replace(self, *args):
+ return None
+ return MyStr('name')
+ t = self.theclass(2005, 3, 2, 0, 0, 0, 0, MyTzInfo(3, 'name'))
+ self.assertRaises(TypeError, t.strftime, '%Z')
+
def test_bad_constructor_arguments(self):
# bad years
self.theclass(MINYEAR, 1, 1) # no exception