Fix issue 2782: be less strict about the format string type in strftime.

Accept unicode and anything else ParseTuple "s#" can deal with.  This
matches the time.strftime behavior.
This commit is contained in:
Gregory P. Smith 2008-06-02 04:05:52 +00:00
parent 8856ddae25
commit 137d824148
3 changed files with 32 additions and 21 deletions

View file

@ -850,9 +850,13 @@ class TestDate(HarmlessMixedComparison, unittest.TestCase):
self.assertRaises(TypeError, t.strftime, "one", "two") # too many args
self.assertRaises(TypeError, t.strftime, 42) # arg wrong type
# test that unicode input is allowed (issue 2782)
self.assertEqual(t.strftime(u"%m"), "03")
# A naive object replaces %z and %Z w/ empty strings.
self.assertEqual(t.strftime("'%z' '%Z'"), "'' ''")
def test_format(self):
dt = self.theclass(2007, 9, 10)
self.assertEqual(dt.__format__(''), str(dt))