diff options
author | Walter Dörwald <walter@livinglogic.de> | 2007-05-31 19:23:17 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2007-05-31 19:23:17 (GMT) |
commit | cf47af4d713f4993ee9326f83dc79197896c1b9a (patch) | |
tree | c67acc049c80b988944e23ed8901024e32edd589 /Modules/timemodule.c | |
parent | baf853c5376b9fbbf4f8644de756e36778b3a2be (diff) | |
download | cpython-cf47af4d713f4993ee9326f83dc79197896c1b9a.zip cpython-cf47af4d713f4993ee9326f83dc79197896c1b9a.tar.gz cpython-cf47af4d713f4993ee9326f83dc79197896c1b9a.tar.bz2 |
Change time.strftime() to return a unicode string.
Use PyMem_Malloc() to allocate temporary storage.
Diffstat (limited to 'Modules/timemodule.c')
-rw-r--r-- | Modules/timemodule.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/Modules/timemodule.c b/Modules/timemodule.c index 4e24299..c7cd340 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -475,7 +475,7 @@ time_strftime(PyObject *self, PyObject *args) * will be ahead of time... */ for (i = 1024; ; i += i) { - outbuf = (char *)malloc(i); + outbuf = (char *)PyMem_Malloc(i); if (outbuf == NULL) { return PyErr_NoMemory(); } @@ -487,11 +487,11 @@ time_strftime(PyObject *self, PyObject *args) e.g. an empty format, or %Z when the timezone is unknown. */ PyObject *ret; - ret = PyString_FromStringAndSize(outbuf, buflen); - free(outbuf); + ret = PyUnicode_FromStringAndSize(outbuf, buflen); + PyMem_Free(outbuf); return ret; } - free(outbuf); + PyMem_Free(outbuf); #if defined _MSC_VER && _MSC_VER >= 1400 && defined(__STDC_SECURE_LIB__) /* VisualStudio .NET 2005 does this properly */ if (buflen == 0 && errno == EINVAL) { @@ -499,7 +499,6 @@ time_strftime(PyObject *self, PyObject *args) return 0; } #endif - } } |