[Python-3000-checkins] r59115 - python/branches/py3k/Modules/datetimemodule.c

walter.doerwald python-3000-checkins at python.org
Thu Nov 22 10:38:52 CET 2007


Author: walter.doerwald
Date: Thu Nov 22 10:38:52 2007
New Revision: 59115

Modified:
   python/branches/py3k/Modules/datetimemodule.c
Log:
Use PyString instead of PyBytes in wrap_strftime().


Modified: python/branches/py3k/Modules/datetimemodule.c
==============================================================================
--- python/branches/py3k/Modules/datetimemodule.c	(original)
+++ python/branches/py3k/Modules/datetimemodule.c	Thu Nov 22 10:38:52 2007
@@ -1237,9 +1237,9 @@
 	 * is expensive, don't unless they're actually used.
 	 */
 	totalnew = flen + 1;	/* realistic if no %z/%Z */
-	newfmt = PyBytes_FromStringAndSize(NULL, totalnew);
+	newfmt = PyString_FromStringAndSize(NULL, totalnew);
 	if (newfmt == NULL) goto Done;
-	pnew = PyBytes_AsString(newfmt);
+	pnew = PyString_AsString(newfmt);
 	usednew = 0;
 
 	while ((ch = *pin++) != '\0') {
@@ -1259,7 +1259,7 @@
 				/* format utcoffset */
 				char buf[100];
 				PyObject *tzinfo = get_tzinfo_member(object);
-				zreplacement = PyBytes_FromStringAndSize("", 0);
+				zreplacement = PyString_FromStringAndSize("", 0);
 				if (zreplacement == NULL) goto Done;
 				if (tzinfo != Py_None && tzinfo != NULL) {
 					assert(tzinfoarg != NULL);
@@ -1271,15 +1271,15 @@
 						goto Done;
 					Py_DECREF(zreplacement);
 					zreplacement =
-					  PyBytes_FromStringAndSize(buf,
+					  PyString_FromStringAndSize(buf,
 								   strlen(buf));
 					if (zreplacement == NULL)
 						goto Done;
 				}
 			}
 			assert(zreplacement != NULL);
-			ptoappend = PyBytes_AS_STRING(zreplacement);
-			ntoappend = PyBytes_GET_SIZE(zreplacement);
+			ptoappend = PyString_AS_STRING(zreplacement);
+			ntoappend = PyString_GET_SIZE(zreplacement);
 		}
 		else if (ch == 'Z') {
 			/* format tzname */
@@ -1314,10 +1314,10 @@
  				PyErr_NoMemory();
  				goto Done;
  			}
- 			if (PyBytes_Resize(newfmt, bigger) < 0)
+ 			if (_PyString_Resize(&newfmt, bigger) < 0)
  				goto Done;
  			totalnew = bigger;
- 			pnew = PyBytes_AsString(newfmt) + usednew;
+ 			pnew = PyString_AsString(newfmt) + usednew;
  		}
 		memcpy(pnew, ptoappend, ntoappend);
 		pnew += ntoappend;
@@ -1325,14 +1325,14 @@
 		assert(usednew <= totalnew);
 	}  /* end while() */
 
-	if (PyBytes_Resize(newfmt, usednew) < 0)
+	if (_PyString_Resize(&newfmt, usednew) < 0)
 		goto Done;
 	{
 		PyObject *format;
 		PyObject *time = PyImport_ImportModule("time");
 		if (time == NULL)
 			goto Done;
-		format = PyUnicode_FromString(PyBytes_AS_STRING(newfmt));
+		format = PyUnicode_FromString(PyString_AS_STRING(newfmt));
 		if (format != NULL) {
 			result = PyObject_CallMethod(time, "strftime", "OO",
 						     format, timetuple);


More information about the Python-3000-checkins mailing list