Index: datetimemodule.c
===================================================================
--- datetimemodule.c (revision 57420)
+++ datetimemodule.c (working copy)
@@ -1338,8 +1338,13 @@
PyObject *time = PyImport_ImportModule("time");
if (time == NULL)
goto Done;
- result = PyObject_CallMethod(time, "strftime", "OO",
- PyUnicode_FromString(PyBytes_AS_STRING(newfmt)), timetuple);
+ PyObject *arg = PyUnicode_FromString(PyBytes_AS_STRING(newfmt));
+ if (arg == NULL) {
+ Py_DECREF(time);
+ goto Done;
+ }
+ result = PyObject_CallMethod(time, "strftime", "OO", arg, timetuple);
+ Py_DECREF(arg);
Py_DECREF(time);
}
Done:
Index: timemodule.c
===================================================================
--- timemodule.c (revision 57420)
+++ timemodule.c (working copy)
@@ -506,7 +506,7 @@
/* Convert the unicode string to an ascii one */
fmt = PyUnicode_AsString(format);
- fmtlen = strlen(fmt);
+ fmtlen = PyUnicode_GET_SIZE(format);
/* I hate these functions that presume you know how big the output
* will be ahead of time...