[Python-3000-checkins] r55718 - python/branches/py3k-struni/Modules/timemodule.c

walter.doerwald python-3000-checkins at python.org
Thu May 31 21:23:19 CEST 2007


Author: walter.doerwald
Date: Thu May 31 21:23:17 2007
New Revision: 55718

Modified:
   python/branches/py3k-struni/Modules/timemodule.c
Log:
Change time.strftime() to return a unicode string.

Use PyMem_Malloc() to allocate temporary storage.


Modified: python/branches/py3k-struni/Modules/timemodule.c
==============================================================================
--- python/branches/py3k-struni/Modules/timemodule.c	(original)
+++ python/branches/py3k-struni/Modules/timemodule.c	Thu May 31 21:23:17 2007
@@ -475,7 +475,7 @@
 	 * 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 @@
 			   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 @@
 			return 0;
 		}
 #endif
-		
 	}
 }
 


More information about the Python-3000-checkins mailing list