summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@microsoft.com>2015-09-07 05:27:42 (GMT)
committerSteve Dower <steve.dower@microsoft.com>2015-09-07 05:27:42 (GMT)
commitf35bd306ffa2c05a1297435bb15cd3b4d47b3977 (patch)
tree8a909b9eb6a5325a5ebbcbdc5858dd798d78db0d /Modules
parentda19767b86dcee5810ad8c77a05811be041d7c89 (diff)
parentc1635e497d060bae076127152801af2b2ec552ff (diff)
downloadcpython-f35bd306ffa2c05a1297435bb15cd3b4d47b3977.zip
cpython-f35bd306ffa2c05a1297435bb15cd3b4d47b3977.tar.gz
cpython-f35bd306ffa2c05a1297435bb15cd3b4d47b3977.tar.bz2
Merge from 3.5.0 branch.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_testmultiphase.c10
-rw-r--r--Modules/timemodule.c16
2 files changed, 20 insertions, 6 deletions
diff --git a/Modules/_testmultiphase.c b/Modules/_testmultiphase.c
index 2919687..2005205 100644
--- a/Modules/_testmultiphase.c
+++ b/Modules/_testmultiphase.c
@@ -582,3 +582,13 @@ PyInit__testmultiphase_exec_unreported_exception(PyObject *spec)
{
return PyModuleDef_Init(&def_exec_unreported_exception);
}
+
+/*** Helper for imp test ***/
+
+static PyModuleDef imp_dummy_def = TEST_MODULE_DEF("imp_dummy", main_slots, testexport_methods);
+
+PyMODINIT_FUNC
+PyInit_imp_dummy(PyObject *spec)
+{
+ return PyModuleDef_Init(&imp_dummy_def);
+}
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index 197d2c0..eca67d9 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -610,14 +610,15 @@ time_strftime(PyObject *self, PyObject *args)
#if defined(MS_WINDOWS) && !defined(HAVE_WCSFTIME)
/* check that the format string contains only valid directives */
- for(outbuf = strchr(fmt, '%');
+ for (outbuf = strchr(fmt, '%');
outbuf != NULL;
outbuf = strchr(outbuf+2, '%'))
{
- if (outbuf[1]=='#')
+ if (outbuf[1] == '#')
++outbuf; /* not documented by python, */
- if ((outbuf[1] == 'y') && buf.tm_year < 0)
- {
+ if (outbuf[1] == '\0')
+ break;
+ if ((outbuf[1] == 'y') && buf.tm_year < 0) {
PyErr_SetString(PyExc_ValueError,
"format %y requires year >= 1900 on Windows");
Py_DECREF(format);
@@ -625,10 +626,12 @@ time_strftime(PyObject *self, PyObject *args)
}
}
#elif (defined(_AIX) || defined(sun)) && defined(HAVE_WCSFTIME)
- for(outbuf = wcschr(fmt, '%');
+ for (outbuf = wcschr(fmt, '%');
outbuf != NULL;
outbuf = wcschr(outbuf+2, '%'))
{
+ if (outbuf[1] == L'\0')
+ break;
/* Issue #19634: On AIX, wcsftime("y", (1899, 1, 1, 0, 0, 0, 0, 0, 0))
returns "0/" instead of "99" */
if (outbuf[1] == L'y' && buf.tm_year < 0) {
@@ -659,7 +662,8 @@ time_strftime(PyObject *self, PyObject *args)
#if defined _MSC_VER && _MSC_VER >= 1400 && defined(__STDC_SECURE_LIB__)
err = errno;
#endif
- if (buflen > 0 || i >= 256 * fmtlen) {
+ if (buflen > 0 || fmtlen == 0 ||
+ (fmtlen > 4 && i >= 256 * fmtlen)) {
/* If the buffer is 256 times as long as the format,
it's probably not failing for lack of room!
More likely, the format yields an empty result,