# HG changeset patch # User Steve Dower # Date 1432139571 25200 # Wed May 20 09:32:51 2015 -0700 # Node ID 0991794c25b62e836d9bbe7cb3dab187cfe8ed4f # Parent b9f436efe48c18091d759c8a1c75ef817303c8f1 Issue 24244: Prevents termination when an invalid format string is encountered on Windows. diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -52,6 +52,9 @@ Library ------- +- Issue 24244: Prevents termination when an invalid format string is + encountered on Windows. + - Issue #22955: attrgetter, itemgetter and methodcaller objects in the operator module now support pickling. Added readable and evaluable repr for these objects. Based on patch by Josh Rosenberg. diff --git a/Modules/timemodule.c b/Modules/timemodule.c --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -616,13 +616,6 @@ { 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 @@ 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