diff options
-rw-r--r-- | Lib/test/test_datetime.py | 1 | ||||
-rw-r--r-- | Modules/datetimemodule.c | 2 |
2 files changed, 2 insertions, 1 deletions
diff --git a/Lib/test/test_datetime.py b/Lib/test/test_datetime.py index cca0c9d..c6dbb48 100644 --- a/Lib/test/test_datetime.py +++ b/Lib/test/test_datetime.py @@ -831,6 +831,7 @@ class TestDate(HarmlessMixedComparison): def test_strftime(self): t = self.theclass(2005, 3, 2) self.assertEqual(t.strftime("m:%m d:%d y:%y"), "m:03 d:02 y:05") + self.assertEqual(t.strftime(""), "") # SF bug #761337 self.assertRaises(TypeError, t.strftime) # needs an arg self.assertRaises(TypeError, t.strftime, "one", "two") # too many args diff --git a/Modules/datetimemodule.c b/Modules/datetimemodule.c index 164492e..d8aed17 100644 --- a/Modules/datetimemodule.c +++ b/Modules/datetimemodule.c @@ -1175,7 +1175,7 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple, * a new format. Since computing the replacements for those codes * is expensive, don't unless they're actually used. */ - totalnew = PyString_Size(format); /* realistic if no %z/%Z */ + totalnew = PyString_Size(format) + 1; /* realistic if no %z/%Z */ newfmt = PyString_FromStringAndSize(NULL, totalnew); if (newfmt == NULL) goto Done; pnew = PyString_AsString(newfmt); |