]> granicus.if.org Git - python/commitdiff
Issue 24244: Prevents termination when an invalid format string is encountered on...
authorSteve Dower <steve.dower@microsoft.com>
Fri, 22 May 2015 22:08:34 +0000 (15:08 -0700)
committerSteve Dower <steve.dower@microsoft.com>
Fri, 22 May 2015 22:08:34 +0000 (15:08 -0700)
Misc/NEWS
Modules/timemodule.c

index 8a1c77943f15514c989c7d0abb643e17f29d2efb..a62cca1fe2ab231101e377a7836f1ff0e82e4611 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -58,6 +58,9 @@ Core and Builtins
 Library
 -------
 
+- Issue 24244: Prevents termination when an invalid format string is
+  encountered on Windows in strftime.
+
 - Issue #23973: PEP 484: Add the typing module.
 
 - Issue #20035: Replaced the ``tkinter._fix`` module used for setting up the
index 5f6290d98ff3160f1bab6ddb3f62a0c7d4b67711..197d2c0b8dd357eaf60e6f90c6c638d83199691d 100644 (file)
@@ -616,13 +616,6 @@ time_strftime(PyObject *self, PyObject *args)
     {
         if (outbuf[1]=='#')
             ++outbuf; /* not documented by python, */
-        if (outbuf[1]=='\0' ||
-            !strchr("aAbBcdHIjmMpSUwWxXyYzZ%", outbuf[1]))
-        {
-            PyErr_SetString(PyExc_ValueError, "Invalid format string");
-            Py_DECREF(format);
-            return NULL;
-        }
         if ((outbuf[1] == 'y') && buf.tm_year < 0)
         {
             PyErr_SetString(PyExc_ValueError,
@@ -660,7 +653,9 @@ time_strftime(PyObject *self, PyObject *args)
             PyErr_NoMemory();
             break;
         }
+        _Py_BEGIN_SUPPRESS_IPH
         buflen = format_time(outbuf, i, fmt, &buf);
+        _Py_END_SUPPRESS_IPH
 #if defined _MSC_VER && _MSC_VER >= 1400 && defined(__STDC_SECURE_LIB__)
         err = errno;
 #endif