diff Modules/_codecsmodule.c @ 47527:52294af4b663 legacy-trunk

This reverts r63675 based on the discussion in this thread: http://mail.python.org/pipermail/python-dev/2008-June/079988.html Python 2.6 should stick with PyString_* in its codebase. The PyBytes_* names in the spirit of 3.0 are available via a #define only. See the email thread.
author Gregory P. Smith <greg@mad-scientist.com>
date Mon, 09 Jun 2008 04:58:54 +0000
parents 4fe192d48960
children b8c4bf393794
line wrap: on
line diff
--- a/Modules/_codecsmodule.c	Mon Jun 09 01:28:30 2008 +0000
+++ b/Modules/_codecsmodule.c	Mon Jun 09 04:58:54 2008 +0000
@@ -168,7 +168,7 @@
     if (!PyArg_ParseTuple(args, "s#|z:escape_decode",
 			  &data, &size, &errors))
 	return NULL;
-    return codec_tuple(PyBytes_DecodeEscape(data, size, errors, 0, NULL),
+    return codec_tuple(PyString_DecodeEscape(data, size, errors, 0, NULL),
 		       size);
 }
 
@@ -182,21 +182,21 @@
 	Py_ssize_t len;
 
 	if (!PyArg_ParseTuple(args, "O!|z:escape_encode",
-			      &PyBytes_Type, &str, &errors))
+			      &PyString_Type, &str, &errors))
 		return NULL;
 
-	str = PyBytes_Repr(str, 0);
+	str = PyString_Repr(str, 0);
 	if (!str)
 		return NULL;
 
 	/* The string will be quoted. Unquote, similar to unicode-escape. */
-	buf = PyBytes_AS_STRING (str);
-	len = PyBytes_GET_SIZE (str);
+	buf = PyString_AS_STRING (str);
+	len = PyString_GET_SIZE (str);
 	memmove(buf, buf+1, len-2);
-	if (_PyBytes_Resize(&str, len-2) < 0)
+	if (_PyString_Resize(&str, len-2) < 0)
 		return NULL;
 	
-	return codec_tuple(str, PyBytes_Size(str));
+	return codec_tuple(str, PyString_Size(str));
 }
 
 #ifdef Py_USING_UNICODE
@@ -640,7 +640,7 @@
 			  &data, &size, &errors))
 	return NULL;
 
-    return codec_tuple(PyBytes_FromStringAndSize(data, size),
+    return codec_tuple(PyString_FromStringAndSize(data, size),
 		       size);
 }
 
@@ -656,7 +656,7 @@
 			  &data, &size, &errors))
 	return NULL;
 
-    return codec_tuple(PyBytes_FromStringAndSize(data, size),
+    return codec_tuple(PyString_FromStringAndSize(data, size),
 		       size);
 }
 
@@ -676,13 +676,13 @@
     if (PyUnicode_Check(obj)) {
 	data = PyUnicode_AS_DATA(obj);
 	size = PyUnicode_GET_DATA_SIZE(obj);
-	return codec_tuple(PyBytes_FromStringAndSize(data, size),
+	return codec_tuple(PyString_FromStringAndSize(data, size),
 			   size);
     }
     else {
 	if (PyObject_AsReadBuffer(obj, (const void **)&data, &size))
 	    return NULL;
-	return codec_tuple(PyBytes_FromStringAndSize(data, size),
+	return codec_tuple(PyString_FromStringAndSize(data, size),
 			   size);
     }
 }