summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_datetime.py
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2006-03-20 02:05:58 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2006-03-20 02:05:58 (GMT)
commit5a8605ec1cf5cd388dcde9a3cd90b3ef6061bcc7 (patch)
tree3198407fc70ab3378cfc29cf1c5584627e9031e7 /Lib/test/test_datetime.py
parent210256e9bacadaeee1194047074cc1146da48806 (diff)
downloadcpython-5a8605ec1cf5cd388dcde9a3cd90b3ef6061bcc7.zip
cpython-5a8605ec1cf5cd388dcde9a3cd90b3ef6061bcc7.tar.gz
cpython-5a8605ec1cf5cd388dcde9a3cd90b3ef6061bcc7.tar.bz2
Backport 43147:
Fix problem spotted by Coverity that occurs if tzinfo.tzname().replace() returns a non-string when converting %Z.
Diffstat (limited to 'Lib/test/test_datetime.py')
-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 ab7bd71..382ee74 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