From: Georg Brandl Date: Sat, 30 Sep 2006 11:17:39 +0000 (+0000) Subject: Bug #1556784: allow format strings longer than 127 characters in X-Git-Tag: v2.4.4c1~84 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=16e469b249be360094eca7129794e4a15b308301;p=thirdparty%2FPython%2Fcpython.git Bug #1556784: allow format strings longer than 127 characters in datetime's strftime function. (backport from rev. 52072) --- diff --git a/Lib/test/test_datetime.py b/Lib/test/test_datetime.py index 99e1c4bcb38b..52f9317f6a53 100644 --- a/Lib/test/test_datetime.py +++ b/Lib/test/test_datetime.py @@ -844,6 +844,7 @@ class TestDate(HarmlessMixedComparison): 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.assertEqual(t.strftime('x'*1000), 'x'*1000) # SF bug #1556784 self.assertRaises(TypeError, t.strftime) # needs an arg self.assertRaises(TypeError, t.strftime, "one", "two") # too many args diff --git a/Misc/NEWS b/Misc/NEWS index e0f7ec7b6b6b..69d75604a79c 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -67,6 +67,9 @@ Core and builtins Extension Modules ----------------- +- Bug #1556784: allow format strings longer than 127 characters in + datetime's strftime function. + - gcmodule: add a missing incref. - threadmodule: add a missing incref. diff --git a/Modules/datetimemodule.c b/Modules/datetimemodule.c index 6ef674046128..4a7035e7f1ed 100644 --- a/Modules/datetimemodule.c +++ b/Modules/datetimemodule.c @@ -1149,9 +1149,9 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple, PyObject *newfmt = NULL; /* py string, the output format */ char *pnew; /* pointer to available byte in output format */ - char totalnew; /* number bytes total in output format buffer, + int totalnew; /* number bytes total in output format buffer, exclusive of trailing \0 */ - char usednew; /* number bytes used so far in output format buffer */ + int usednew; /* number bytes used so far in output format buffer */ char *ptoappend; /* pointer to string to append to output buffer */ int ntoappend; /* # of bytes to append to output buffer */