[Python-3000-checkins] r63682 - in python/branches/py3k: Include/object.h Include/py_curses.h Include/pyport.h Include/pythonrun.h Include/stringobject.h Modules/_bsddb.c Modules/_bytesio.c Modules/_codecsmodule.c Modules/_ctypes/_ctypes.c Modules/_ctypes/callbacks.c Modules/_ctypes/callproc.c Modules/_ctypes/cfield.c Modules/_cursesmodule.c Modules/_dbmmodule.c Modules/_elementtree.c Modules/_fileio.c Modules/_gdbmmodule.c Modules/_hashopenssl.c Modules/_json.c Modules/_sqlite/connection.c Modules/_sqlite/connection.h Modules/_sqlite/cursor.c Modules/_sqlite/statement.c Modules/_sre.c Modules/_ssl.c Modules/_struct.c Modules/_tkinter.c Modules/arraymodule.c Modules/audioop.c Modules/binascii.c Modules/bz2module.c Modules/cStringIO.c Modules/cjkcodecs/multibytecodec.c Modules/datetimemodule.c Modules/fcntlmodule.c Modules/md5module.c Modules/mmapmodule.c Modules/posixmodule.c Modules/pyexpat.c Modules/selectmodule.c Modules/sha1module.c Modules/sha256module.c Modules/sha512module.c Modules/socketmodule.c Modules/termios.c Objects/abstract.c Objects/bytes_methods.c Objects/bytesobject.c Objects/codeobject.c Objects/exceptions.c Objects/fileobject.c Objects/frameobject.c Objects/longobject.c Objects/object.c Objects/stringlib/formatter.h Objects/stringlib/string_format.h Objects/stringlib/stringdefs.h Objects/stringobject.c Objects/typeobject.c Objects/unicodeobject.c PC/_msi.c PC/msvcrtmodule.c Parser/asdl_c.py Parser/tokenizer.c Python/Python-ast.c Python/ast.c Python/bltinmodule.c Python/ceval.c Python/codecs.c Python/compile.c Python/getargs.c Python/import.c Python/marshal.c Python/modsupport.c Python/peephole.c Python/pystrtod.c Python/pythonrun.c Python/traceback.c

christian.heimes python-3000-checkins at python.org
Mon May 26 15:28:42 CEST 2008


Author: christian.heimes
Date: Mon May 26 15:28:38 2008
New Revision: 63682

Log:
Renamed PyString to PyBytes

Modified:
   python/branches/py3k/Include/object.h
   python/branches/py3k/Include/py_curses.h
   python/branches/py3k/Include/pyport.h
   python/branches/py3k/Include/pythonrun.h
   python/branches/py3k/Include/stringobject.h
   python/branches/py3k/Modules/_bsddb.c
   python/branches/py3k/Modules/_bytesio.c
   python/branches/py3k/Modules/_codecsmodule.c
   python/branches/py3k/Modules/_ctypes/_ctypes.c
   python/branches/py3k/Modules/_ctypes/callbacks.c
   python/branches/py3k/Modules/_ctypes/callproc.c
   python/branches/py3k/Modules/_ctypes/cfield.c
   python/branches/py3k/Modules/_cursesmodule.c
   python/branches/py3k/Modules/_dbmmodule.c
   python/branches/py3k/Modules/_elementtree.c
   python/branches/py3k/Modules/_fileio.c
   python/branches/py3k/Modules/_gdbmmodule.c
   python/branches/py3k/Modules/_hashopenssl.c
   python/branches/py3k/Modules/_json.c
   python/branches/py3k/Modules/_sqlite/connection.c
   python/branches/py3k/Modules/_sqlite/connection.h
   python/branches/py3k/Modules/_sqlite/cursor.c
   python/branches/py3k/Modules/_sqlite/statement.c
   python/branches/py3k/Modules/_sre.c
   python/branches/py3k/Modules/_ssl.c
   python/branches/py3k/Modules/_struct.c
   python/branches/py3k/Modules/_tkinter.c
   python/branches/py3k/Modules/arraymodule.c
   python/branches/py3k/Modules/audioop.c
   python/branches/py3k/Modules/binascii.c
   python/branches/py3k/Modules/bz2module.c
   python/branches/py3k/Modules/cStringIO.c
   python/branches/py3k/Modules/cjkcodecs/multibytecodec.c
   python/branches/py3k/Modules/datetimemodule.c
   python/branches/py3k/Modules/fcntlmodule.c
   python/branches/py3k/Modules/md5module.c
   python/branches/py3k/Modules/mmapmodule.c
   python/branches/py3k/Modules/posixmodule.c
   python/branches/py3k/Modules/pyexpat.c
   python/branches/py3k/Modules/selectmodule.c
   python/branches/py3k/Modules/sha1module.c
   python/branches/py3k/Modules/sha256module.c
   python/branches/py3k/Modules/sha512module.c
   python/branches/py3k/Modules/socketmodule.c
   python/branches/py3k/Modules/termios.c
   python/branches/py3k/Objects/abstract.c
   python/branches/py3k/Objects/bytes_methods.c
   python/branches/py3k/Objects/bytesobject.c
   python/branches/py3k/Objects/codeobject.c
   python/branches/py3k/Objects/exceptions.c
   python/branches/py3k/Objects/fileobject.c
   python/branches/py3k/Objects/frameobject.c
   python/branches/py3k/Objects/longobject.c
   python/branches/py3k/Objects/object.c
   python/branches/py3k/Objects/stringlib/formatter.h
   python/branches/py3k/Objects/stringlib/string_format.h
   python/branches/py3k/Objects/stringlib/stringdefs.h
   python/branches/py3k/Objects/stringobject.c
   python/branches/py3k/Objects/typeobject.c
   python/branches/py3k/Objects/unicodeobject.c
   python/branches/py3k/PC/_msi.c
   python/branches/py3k/PC/msvcrtmodule.c
   python/branches/py3k/Parser/asdl_c.py
   python/branches/py3k/Parser/tokenizer.c
   python/branches/py3k/Python/Python-ast.c
   python/branches/py3k/Python/ast.c
   python/branches/py3k/Python/bltinmodule.c
   python/branches/py3k/Python/ceval.c
   python/branches/py3k/Python/codecs.c
   python/branches/py3k/Python/compile.c
   python/branches/py3k/Python/getargs.c
   python/branches/py3k/Python/import.c
   python/branches/py3k/Python/marshal.c
   python/branches/py3k/Python/modsupport.c
   python/branches/py3k/Python/peephole.c
   python/branches/py3k/Python/pystrtod.c
   python/branches/py3k/Python/pythonrun.c
   python/branches/py3k/Python/traceback.c

Modified: python/branches/py3k/Include/object.h
==============================================================================
--- python/branches/py3k/Include/object.h	(original)
+++ python/branches/py3k/Include/object.h	Mon May 26 15:28:38 2008
@@ -540,7 +540,7 @@
 #define Py_TPFLAGS_LONG_SUBCLASS	(1L<<24)
 #define Py_TPFLAGS_LIST_SUBCLASS	(1L<<25)
 #define Py_TPFLAGS_TUPLE_SUBCLASS	(1L<<26)
-#define Py_TPFLAGS_STRING_SUBCLASS	(1L<<27)
+#define Py_TPFLAGS_BYTES_SUBCLASS	(1L<<27)
 #define Py_TPFLAGS_UNICODE_SUBCLASS	(1L<<28)
 #define Py_TPFLAGS_DICT_SUBCLASS	(1L<<29)
 #define Py_TPFLAGS_BASE_EXC_SUBCLASS	(1L<<30)

Modified: python/branches/py3k/Include/py_curses.h
==============================================================================
--- python/branches/py3k/Include/py_curses.h	(original)
+++ python/branches/py3k/Include/py_curses.h	Mon May 26 15:28:38 2008
@@ -146,7 +146,7 @@
 static PyObject *PyCurses_ ## X (PyObject *self) \
 { \
   PyCursesInitialised \
-  return PyString_FromString(X()); }
+  return PyBytes_FromString(X()); }
 
 #define NoArgTrueFalseFunction(X) \
 static PyObject *PyCurses_ ## X (PyObject *self) \

Modified: python/branches/py3k/Include/pyport.h
==============================================================================
--- python/branches/py3k/Include/pyport.h	(original)
+++ python/branches/py3k/Include/pyport.h	Mon May 26 15:28:38 2008
@@ -124,9 +124,9 @@
  * all platforms (Python interprets the format string itself, and does whatever
  * the platform C requires to convert a size_t/Py_ssize_t argument):
  *
- *     PyString_FromFormat
+ *     PyBytes_FromFormat
  *     PyErr_Format
- *     PyString_FromFormatV
+ *     PyBytes_FromFormatV
  *     PyUnicode_FromFormatV
  *
  * Lower-level uses require that you interpolate the correct format modifier

Modified: python/branches/py3k/Include/pythonrun.h
==============================================================================
--- python/branches/py3k/Include/pythonrun.h	(original)
+++ python/branches/py3k/Include/pythonrun.h	Mon May 26 15:28:38 2008
@@ -138,7 +138,7 @@
 PyAPI_FUNC(void) PyTuple_Fini(void);
 PyAPI_FUNC(void) PyList_Fini(void);
 PyAPI_FUNC(void) PySet_Fini(void);
-PyAPI_FUNC(void) PyString_Fini(void);
+PyAPI_FUNC(void) PyBytes_Fini(void);
 PyAPI_FUNC(void) PyByteArray_Fini(void);
 PyAPI_FUNC(void) PyFloat_Fini(void);
 PyAPI_FUNC(void) PyOS_FiniInterrupts(void);

Modified: python/branches/py3k/Include/stringobject.h
==============================================================================
--- python/branches/py3k/Include/stringobject.h	(original)
+++ python/branches/py3k/Include/stringobject.h	Mon May 26 15:28:38 2008
@@ -10,7 +10,7 @@
 #include <stdarg.h>
 
 /*
-Type PyStringObject represents a character string.  An extra zero byte is
+Type PyBytesObject represents a character string.  An extra zero byte is
 reserved at the end to ensure it is zero-terminated, but a size is
 present so strings with null bytes in them can be represented.  This
 is an immutable object type.
@@ -37,49 +37,49 @@
      *     ob_sval[ob_size] == 0.
      *     ob_shash is the hash of the string or -1 if not computed yet.
      */
-} PyStringObject;
+} PyBytesObject;
 
-PyAPI_DATA(PyTypeObject) PyString_Type;
-PyAPI_DATA(PyTypeObject) PyStringIter_Type;
+PyAPI_DATA(PyTypeObject) PyBytes_Type;
+PyAPI_DATA(PyTypeObject) PyBytesIter_Type;
 
-#define PyString_Check(op) \
-                 PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_STRING_SUBCLASS)
-#define PyString_CheckExact(op) (Py_TYPE(op) == &PyString_Type)
-
-PyAPI_FUNC(PyObject *) PyString_FromStringAndSize(const char *, Py_ssize_t);
-PyAPI_FUNC(PyObject *) PyString_FromString(const char *);
-PyAPI_FUNC(PyObject *) PyString_FromFormatV(const char*, va_list)
+#define PyBytes_Check(op) \
+                 PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_BYTES_SUBCLASS)
+#define PyBytes_CheckExact(op) (Py_TYPE(op) == &PyBytes_Type)
+
+PyAPI_FUNC(PyObject *) PyBytes_FromStringAndSize(const char *, Py_ssize_t);
+PyAPI_FUNC(PyObject *) PyBytes_FromString(const char *);
+PyAPI_FUNC(PyObject *) PyBytes_FromFormatV(const char*, va_list)
 				Py_GCC_ATTRIBUTE((format(printf, 1, 0)));
-PyAPI_FUNC(PyObject *) PyString_FromFormat(const char*, ...)
+PyAPI_FUNC(PyObject *) PyBytes_FromFormat(const char*, ...)
 				Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
-PyAPI_FUNC(Py_ssize_t) PyString_Size(PyObject *);
-PyAPI_FUNC(char *) PyString_AsString(PyObject *);
-PyAPI_FUNC(PyObject *) PyString_Repr(PyObject *, int);
-PyAPI_FUNC(void) PyString_Concat(PyObject **, PyObject *);
-PyAPI_FUNC(void) PyString_ConcatAndDel(PyObject **, PyObject *);
-PyAPI_FUNC(int) _PyString_Resize(PyObject **, Py_ssize_t);
-PyAPI_FUNC(PyObject *) PyString_Format(PyObject *, PyObject *);
-PyAPI_FUNC(PyObject *) _PyString_FormatLong(PyObject*, int, int,
+PyAPI_FUNC(Py_ssize_t) PyBytes_Size(PyObject *);
+PyAPI_FUNC(char *) PyBytes_AsString(PyObject *);
+PyAPI_FUNC(PyObject *) PyBytes_Repr(PyObject *, int);
+PyAPI_FUNC(void) PyBytes_Concat(PyObject **, PyObject *);
+PyAPI_FUNC(void) PyBytes_ConcatAndDel(PyObject **, PyObject *);
+PyAPI_FUNC(int) _PyBytes_Resize(PyObject **, Py_ssize_t);
+PyAPI_FUNC(PyObject *) PyBytes_Format(PyObject *, PyObject *);
+PyAPI_FUNC(PyObject *) _PyBytes_FormatLong(PyObject*, int, int,
 						  int, char**, int*);
-PyAPI_FUNC(PyObject *) PyString_DecodeEscape(const char *, Py_ssize_t,
+PyAPI_FUNC(PyObject *) PyBytes_DecodeEscape(const char *, Py_ssize_t,
 						   const char *, Py_ssize_t,
 						   const char *);
 
 /* Macro, trading safety for speed */
-#define PyString_AS_STRING(op) (assert(PyString_Check(op)), \
-                                (((PyStringObject *)(op))->ob_sval))
-#define PyString_GET_SIZE(op)  (assert(PyString_Check(op)),Py_SIZE(op))
+#define PyBytes_AS_STRING(op) (assert(PyBytes_Check(op)), \
+                                (((PyBytesObject *)(op))->ob_sval))
+#define PyBytes_GET_SIZE(op)  (assert(PyBytes_Check(op)),Py_SIZE(op))
 
-/* _PyString_Join(sep, x) is like sep.join(x).  sep must be PyStringObject*,
+/* _PyBytes_Join(sep, x) is like sep.join(x).  sep must be PyBytesObject*,
    x must be an iterable object. */
-PyAPI_FUNC(PyObject *) _PyString_Join(PyObject *sep, PyObject *x);
+PyAPI_FUNC(PyObject *) _PyBytes_Join(PyObject *sep, PyObject *x);
 
 /* Provides access to the internal data buffer and size of a string
    object or the default encoded version of an Unicode object. Passing
    NULL as *len parameter will force the string buffer to be
    0-terminated (passing a string with embedded NULL characters will
    cause an exception).  */
-PyAPI_FUNC(int) PyString_AsStringAndSize(
+PyAPI_FUNC(int) PyBytes_AsStringAndSize(
     register PyObject *obj,	/* string or Unicode object */
     register char **s,		/* pointer to buffer variable */
     register Py_ssize_t *len	/* pointer to length variable or NULL
@@ -91,7 +91,7 @@
    into the string pointed to by buffer.  For the argument descriptions,
    see Objects/stringlib/localeutil.h */
 
-PyAPI_FUNC(int) _PyString_InsertThousandsGrouping(char *buffer,
+PyAPI_FUNC(int) _PyBytes_InsertThousandsGrouping(char *buffer,
 						  Py_ssize_t len,
 						  char *plast,
 						  Py_ssize_t buf_size,

Modified: python/branches/py3k/Modules/_bsddb.c
==============================================================================
--- python/branches/py3k/Modules/_bsddb.c	(original)
+++ python/branches/py3k/Modules/_bsddb.c	Mon May 26 15:28:38 2008
@@ -1174,7 +1174,7 @@
         else if (PyLong_Check(result)) {
             retval = PyLong_AsLong(result);
         }
-        else if (PyByteArray_Check(result) || PyString_Check(result)) {
+        else if (PyByteArray_Check(result) || PyBytes_Check(result)) {
             char* data;
             Py_ssize_t size;
 
@@ -1183,7 +1183,7 @@
             if (PyByteArray_Check(result))
                 data = PyByteArray_AS_STRING(result);
             else
-                data = PyString_AS_STRING(result);
+                data = PyBytes_AS_STRING(result);
             secKey->flags = DB_DBT_APPMALLOC;   /* DB will free */
             secKey->data = malloc(size);        /* TODO, check this */
 	    if (secKey->data) {
@@ -1523,7 +1523,7 @@
             retval = Py_BuildValue("y#y#", key.data, key.size, data.data,
                                    data.size);
         else /* return just the data */
-            retval = PyString_FromStringAndSize((char*)data.data, data.size);
+            retval = PyBytes_FromStringAndSize((char*)data.data, data.size);
         free_dbt(&data);
     }
     FREE_DBT_VIEW(key, keyobj, key_buf_view);
@@ -1593,13 +1593,13 @@
     else if (!err) {
         PyObject *pkeyObj;
         PyObject *dataObj;
-        dataObj = PyString_FromStringAndSize(data.data, data.size);
+        dataObj = PyBytes_FromStringAndSize(data.data, data.size);
 
         if (self->primaryDBType == DB_RECNO ||
             self->primaryDBType == DB_QUEUE)
             pkeyObj = PyLong_FromLong(*(int *)pkey.data);
         else
-            pkeyObj = PyString_FromStringAndSize(pkey.data, pkey.size);
+            pkeyObj = PyBytes_FromStringAndSize(pkey.data, pkey.size);
 
         if (flags & DB_SET_RECNO) /* return key , pkey and data */
         {
@@ -1608,7 +1608,7 @@
             if (type == DB_RECNO || type == DB_QUEUE)
                 keyObj = PyLong_FromLong(*(int *)key.data);
             else
-                keyObj = PyString_FromStringAndSize(key.data, key.size);
+                keyObj = PyBytes_FromStringAndSize(key.data, key.size);
 #if (PY_VERSION_HEX >= 0x02040000)
             retval = PyTuple_Pack(3, keyObj, pkeyObj, dataObj);
 #else
@@ -1736,7 +1736,7 @@
         /* XXX(nnorwitz): can we do: retval = dataobj; Py_INCREF(retval); */
         /* XXX(gps) I think not: buffer API input vs. bytes object output. */
         /* XXX(guido) But what if the input is PyString? */
-        retval = PyString_FromStringAndSize((char*)data.data, data.size);
+        retval = PyBytes_FromStringAndSize((char*)data.data, data.size);
 
         /* Even though the flags require DB_DBT_MALLOC, data is not always
            allocated.  4.4: allocated, 4.5: *not* allocated. :-( */
@@ -2780,7 +2780,7 @@
         retval = NULL;
     }
     else {
-        retval = PyString_FromStringAndSize((char*)data.data, data.size);
+        retval = PyBytes_FromStringAndSize((char*)data.data, data.size);
         free_dbt(&data);
     }
 
@@ -2935,7 +2935,7 @@
             case DB_BTREE:
             case DB_HASH:
             default:
-                item = PyString_FromStringAndSize((char*)key.data, key.size);
+                item = PyBytes_FromStringAndSize((char*)key.data, key.size);
                 break;
             case DB_RECNO:
             case DB_QUEUE:
@@ -2945,7 +2945,7 @@
             break;
 
         case _VALUES_LIST:
-            item = PyString_FromStringAndSize((char*)data.data, data.size);
+            item = PyBytes_FromStringAndSize((char*)data.data, data.size);
             break;
 
         case _ITEMS_LIST:
@@ -3293,13 +3293,13 @@
     else {
         PyObject *pkeyObj;
         PyObject *dataObj;
-        dataObj = PyString_FromStringAndSize(data.data, data.size);
+        dataObj = PyBytes_FromStringAndSize(data.data, data.size);
 
         if (self->mydb->primaryDBType == DB_RECNO ||
             self->mydb->primaryDBType == DB_QUEUE)
             pkeyObj = PyLong_FromLong(*(int *)pkey.data);
         else
-            pkeyObj = PyString_FromStringAndSize(pkey.data, pkey.size);
+            pkeyObj = PyBytes_FromStringAndSize(pkey.data, pkey.size);
 
         if (key.data && key.size) /* return key, pkey and data */
         {
@@ -3308,7 +3308,7 @@
             if (type == DB_RECNO || type == DB_QUEUE)
                 keyObj = PyLong_FromLong(*(int *)key.data);
             else
-                keyObj = PyString_FromStringAndSize(key.data, key.size);
+                keyObj = PyBytes_FromStringAndSize(key.data, key.size);
             retval = PyTuple_Pack(3, keyObj, pkeyObj, dataObj);
             Py_DECREF(keyObj);
         }
@@ -4916,7 +4916,7 @@
     MYDB_END_ALLOW_THREADS
 
     if (!err)
-        retval = PyString_FromStringAndSize(key.data, key.size);
+        retval = PyBytes_FromStringAndSize(key.data, key.size);
 
     free_dbt(&key);
     RETURN_IF_ERR();

Modified: python/branches/py3k/Modules/_bytesio.c
==============================================================================
--- python/branches/py3k/Modules/_bytesio.c	(original)
+++ python/branches/py3k/Modules/_bytesio.c	Mon May 26 15:28:38 2008
@@ -175,7 +175,7 @@
 bytesio_getvalue(BytesIOObject *self)
 {
     CHECK_CLOSED(self);
-    return PyString_FromStringAndSize(self->buf, self->string_size);
+    return PyBytes_FromStringAndSize(self->buf, self->string_size);
 }
 
 PyDoc_STRVAR(isatty_doc,
@@ -244,7 +244,7 @@
     output = self->buf + self->pos;
     self->pos += size;
 
-    return PyString_FromStringAndSize(output, size);
+    return PyBytes_FromStringAndSize(output, size);
 }
 
 
@@ -307,7 +307,7 @@
         self->pos -= size;
     }
 
-    return PyString_FromStringAndSize(output, n);
+    return PyBytes_FromStringAndSize(output, n);
 }
 
 PyDoc_STRVAR(readlines_doc,
@@ -349,7 +349,7 @@
         return NULL;
 
     while ((n = get_line(self, &output)) != 0) {
-        line = PyString_FromStringAndSize(output, n);
+        line = PyBytes_FromStringAndSize(output, n);
         if (!line)
             goto on_error;
         if (PyList_Append(result, line) == -1) {
@@ -455,7 +455,7 @@
     if (!next || n == 0)
         return NULL;
 
-    return PyString_FromStringAndSize(next, n);
+    return PyBytes_FromStringAndSize(next, n);
 }
 
 PyDoc_STRVAR(seek_doc,

Modified: python/branches/py3k/Modules/_codecsmodule.c
==============================================================================
--- python/branches/py3k/Modules/_codecsmodule.c	(original)
+++ python/branches/py3k/Modules/_codecsmodule.c	Mon May 26 15:28:38 2008
@@ -154,7 +154,7 @@
     if (!PyArg_ParseTuple(args, "s#|z:escape_decode",
 			  &data, &size, &errors))
 	return NULL;
-    return codec_tuple(PyString_DecodeEscape(data, size, errors, 0, NULL),
+    return codec_tuple(PyBytes_DecodeEscape(data, size, errors, 0, NULL),
 		       size);
 }
 
@@ -170,17 +170,17 @@
 	PyObject *v;
 
 	if (!PyArg_ParseTuple(args, "O!|z:escape_encode",
-			      &PyString_Type, &str, &errors))
+			      &PyBytes_Type, &str, &errors))
 		return NULL;
 
-	size = PyString_GET_SIZE(str);
+	size = PyBytes_GET_SIZE(str);
 	newsize = 4*size;
 	if (newsize > PY_SSIZE_T_MAX || newsize / 4 != size) {
 		PyErr_SetString(PyExc_OverflowError,
 			"string is too large to encode");
 			return NULL;
 	}
-	v = PyString_FromStringAndSize(NULL, newsize);
+	v = PyBytes_FromStringAndSize(NULL, newsize);
 
 	if (v == NULL) {
 		return NULL;
@@ -188,12 +188,12 @@
 	else {
 		register Py_ssize_t i;
 		register char c;
-		register char *p = PyString_AS_STRING(v);
+		register char *p = PyBytes_AS_STRING(v);
 
 		for (i = 0; i < size; i++) {
 			/* There's at least enough room for a hex escape */
-			assert(newsize - (p - PyString_AS_STRING(v)) >= 4);
-			c = PyString_AS_STRING(str)[i];
+			assert(newsize - (p - PyBytes_AS_STRING(v)) >= 4);
+			c = PyBytes_AS_STRING(str)[i];
 			if (c == '\'' || c == '\\')
 				*p++ = '\\', *p++ = c;
 			else if (c == '\t')
@@ -212,12 +212,12 @@
 				*p++ = c;
 		}
 		*p = '\0';
-		if (_PyString_Resize(&v, (p - PyString_AS_STRING(v)))) {
+		if (_PyBytes_Resize(&v, (p - PyBytes_AS_STRING(v)))) {
 			return NULL;
 		}
 	}
 	
-	return codec_tuple(v, PyString_Size(v));
+	return codec_tuple(v, PyBytes_Size(v));
 }
 
 /* --- Decoder ------------------------------------------------------------ */
@@ -660,7 +660,7 @@
 			  &data, &size, &errors))
 	return NULL;
 
-    return codec_tuple(PyString_FromStringAndSize(data, size), size);
+    return codec_tuple(PyBytes_FromStringAndSize(data, size), size);
 }
 
 static PyObject *
@@ -675,7 +675,7 @@
 			  &data, &size, &errors))
 	return NULL;
 
-    return codec_tuple(PyString_FromStringAndSize(data, size), size);
+    return codec_tuple(PyBytes_FromStringAndSize(data, size), size);
 }
 
 static PyObject *
@@ -694,12 +694,12 @@
     if (PyUnicode_Check(obj)) {
 	data = PyUnicode_AS_DATA(obj);
 	size = PyUnicode_GET_DATA_SIZE(obj);
-	return codec_tuple(PyString_FromStringAndSize(data, size), size);
+	return codec_tuple(PyBytes_FromStringAndSize(data, size), size);
     }
     else {
 	if (PyObject_AsReadBuffer(obj, (const void **)&data, &size))
 	    return NULL;
-	return codec_tuple(PyString_FromStringAndSize(data, size), size);
+	return codec_tuple(PyBytes_FromStringAndSize(data, size), size);
     }
 }
 

Modified: python/branches/py3k/Modules/_ctypes/_ctypes.c
==============================================================================
--- python/branches/py3k/Modules/_ctypes/_ctypes.c	(original)
+++ python/branches/py3k/Modules/_ctypes/_ctypes.c	Mon May 26 15:28:38 2008
@@ -1049,7 +1049,7 @@
 static PyObject *
 CharArray_get_raw(CDataObject *self)
 {
-	return PyString_FromStringAndSize(self->b_ptr, self->b_size);
+	return PyBytes_FromStringAndSize(self->b_ptr, self->b_size);
 }
 
 static PyObject *
@@ -1060,7 +1060,7 @@
 	for (i = 0; i < self->b_size; ++i)
 		if (*ptr++ == '\0')
 			break;
-	return PyString_FromStringAndSize(self->b_ptr, i);
+	return PyBytes_FromStringAndSize(self->b_ptr, i);
 }
 
 static int
@@ -1081,14 +1081,14 @@
 						  conversion_mode_errors);
 		if (!value)
 			return -1;
-	} else if (!PyString_Check(value)) {
+	} else if (!PyBytes_Check(value)) {
 		PyErr_Format(PyExc_TypeError,
 			     "str/bytes expected instead of %s instance",
 			     Py_TYPE(value)->tp_name);
 		return -1;
 	} else
 		Py_INCREF(value);
-	size = PyString_GET_SIZE(value);
+	size = PyBytes_GET_SIZE(value);
 	if (size > self->b_size) {
 		PyErr_SetString(PyExc_ValueError,
 				"string too long");
@@ -1096,7 +1096,7 @@
 		return -1;
 	}
 
-	ptr = PyString_AS_STRING(value);
+	ptr = PyBytes_AS_STRING(value);
 	memcpy(self->b_ptr, ptr, size);
 	if (size < self->b_size)
 		self->b_ptr[size] = '\0';
@@ -1135,7 +1135,7 @@
 				"can't delete attribute");
 		return -1;
 	}
-	if (PyString_Check(value)) {
+	if (PyBytes_Check(value)) {
 		value = PyUnicode_FromEncodedObject(value,
 						    conversion_mode_encoding,
 						    conversion_mode_errors);
@@ -1434,7 +1434,7 @@
 		Py_INCREF(Py_None);
 		return Py_None;
 	}
-	if (PyUnicode_Check(value) || PyString_Check(value)) {
+	if (PyUnicode_Check(value) || PyBytes_Check(value)) {
 		PyCArgObject *parg;
 		struct fielddesc *fd = getentry("Z");
 
@@ -1495,7 +1495,7 @@
 		Py_INCREF(Py_None);
 		return Py_None;
 	}
-	if (PyString_Check(value) || PyUnicode_Check(value)) {
+	if (PyBytes_Check(value) || PyUnicode_Check(value)) {
 		PyCArgObject *parg;
 		struct fielddesc *fd = getentry("z");
 
@@ -1579,7 +1579,7 @@
 	}
 	/* XXX struni: remove later */
 /* string */
-	if (PyString_Check(value)) {
+	if (PyBytes_Check(value)) {
 		PyCArgObject *parg;
 		struct fielddesc *fd = getentry("z");
 
@@ -1828,8 +1828,8 @@
 		PyObject *v = _PyUnicode_AsDefaultEncodedString(proto, NULL);
 		if (!v)
 			goto error;
-		proto_str = PyString_AS_STRING(v);
-		proto_len = PyString_GET_SIZE(v);
+		proto_str = PyBytes_AS_STRING(v);
+		proto_len = PyBytes_GET_SIZE(v);
 	} else {
 		PyErr_SetString(PyExc_TypeError,
 			"class must define a '_type_' string attribute");
@@ -2501,7 +2501,7 @@
 			     _unpickle,
 			     Py_TYPE(_self),
 			     PyObject_GetAttrString(_self, "__dict__"),
-			     PyString_FromStringAndSize(self->b_ptr, self->b_size));
+			     PyBytes_FromStringAndSize(self->b_ptr, self->b_size));
 }
 
 static PyObject *
@@ -3137,8 +3137,8 @@
 		return 1;
 	}
 #endif
-	if (PyString_Check(obj)) {
-		*pname = PyString_AS_STRING(obj);
+	if (PyBytes_Check(obj)) {
+		*pname = PyBytes_AS_STRING(obj);
 		return *pname ? 1 : 0;
 	}
 	if (PyUnicode_Check(obj)) {
@@ -3953,7 +3953,7 @@
 			}
 
 			if (kwds && PyDict_GetItem(kwds, name)) {
-				char *field = PyString_AsString(name);
+				char *field = PyBytes_AsString(name);
 				if (field == NULL) {
 					PyErr_Clear();
 					field = "???";
@@ -4166,9 +4166,9 @@
 			char *dest;
 
 			if (slicelen <= 0)
-				return PyString_FromStringAndSize("", 0);
+				return PyBytes_FromStringAndSize("", 0);
 			if (step == 1) {
-				return PyString_FromStringAndSize(ptr + start,
+				return PyBytes_FromStringAndSize(ptr + start,
 								 slicelen);
 			}
 			dest = (char *)PyMem_Malloc(slicelen);
@@ -4181,7 +4181,7 @@
 				dest[i] = ptr[cur];
 			}
 
-			np = PyString_FromStringAndSize(dest, slicelen);
+			np = PyBytes_FromStringAndSize(dest, slicelen);
 			PyMem_Free(dest);
 			return np;
 		}
@@ -4859,9 +4859,9 @@
 			char *dest;
 			
 			if (len <= 0)
-                        	return PyString_FromStringAndSize("", 0);
+                        	return PyBytes_FromStringAndSize("", 0);
 			if (step == 1) {
-				return PyString_FromStringAndSize(ptr + start,
+				return PyBytes_FromStringAndSize(ptr + start,
 								 len);
 			}
 			dest = (char *)PyMem_Malloc(len);
@@ -4870,7 +4870,7 @@
 			for (cur = start, i = 0; i < len; cur += step, i++) {
 				dest[i] = ptr[cur];
 			}
-			np = PyString_FromStringAndSize(dest, len);
+			np = PyBytes_FromStringAndSize(dest, len);
 			PyMem_Free(dest);
 			return np;
 		}
@@ -5105,8 +5105,8 @@
 string_at(const char *ptr, int size)
 {
 	if (size == -1)
-		return PyString_FromStringAndSize(ptr, strlen(ptr));
-	return PyString_FromStringAndSize(ptr, size);
+		return PyBytes_FromStringAndSize(ptr, strlen(ptr));
+	return PyBytes_FromStringAndSize(ptr, size);
 }
 
 static int

Modified: python/branches/py3k/Modules/_ctypes/callbacks.c
==============================================================================
--- python/branches/py3k/Modules/_ctypes/callbacks.c	(original)
+++ python/branches/py3k/Modules/_ctypes/callbacks.c	Mon May 26 15:28:38 2008
@@ -110,7 +110,7 @@
 	if (!py_globals) goto bad;
 	empty_tuple = PyTuple_New(0);
 	if (!empty_tuple) goto bad;
-	empty_string = PyString_FromString("");
+	empty_string = PyBytes_FromString("");
 	if (!empty_string) goto bad;
 	py_code = PyCode_New(
 		0,            /*int argcount,*/

Modified: python/branches/py3k/Modules/_ctypes/callproc.c
==============================================================================
--- python/branches/py3k/Modules/_ctypes/callproc.c	(original)
+++ python/branches/py3k/Modules/_ctypes/callproc.c	Mon May 26 15:28:38 2008
@@ -507,9 +507,9 @@
 		return 0;
 	}
 
-	if (PyString_Check(obj)) {
+	if (PyBytes_Check(obj)) {
 		pa->ffi_type = &ffi_type_pointer;
-		pa->value.p = PyString_AsString(obj);
+		pa->value.p = PyBytes_AsString(obj);
 		Py_INCREF(obj);
 		pa->keep = obj;
 		return 0;

Modified: python/branches/py3k/Modules/_ctypes/cfield.c
==============================================================================
--- python/branches/py3k/Modules/_ctypes/cfield.c	(original)
+++ python/branches/py3k/Modules/_ctypes/cfield.c	Mon May 26 15:28:38 2008
@@ -1160,16 +1160,16 @@
 						  conversion_mode_errors);
 		if (value == NULL)
 			return NULL;
-		if (PyString_GET_SIZE(value) != 1) {
+		if (PyBytes_GET_SIZE(value) != 1) {
 			Py_DECREF(value);
 			goto error;
 		}
-		*(char *)ptr = PyString_AS_STRING(value)[0];
+		*(char *)ptr = PyBytes_AS_STRING(value)[0];
 		Py_DECREF(value);
 		_RET(value);
 	}
-	if (PyString_Check(value) && PyString_GET_SIZE(value) == 1) {
-		*(char *)ptr = PyString_AS_STRING(value)[0];
+	if (PyBytes_Check(value) && PyBytes_GET_SIZE(value) == 1) {
+		*(char *)ptr = PyBytes_AS_STRING(value)[0];
 		_RET(value);
 	}
 	if (PyByteArray_Check(value) && PyByteArray_GET_SIZE(value) == 1) {
@@ -1194,7 +1194,7 @@
 static PyObject *
 c_get(void *ptr, Py_ssize_t size)
 {
-	return PyString_FromStringAndSize((char *)ptr, 1);
+	return PyBytes_FromStringAndSize((char *)ptr, 1);
 }
 
 #ifdef CTYPES_UNICODE
@@ -1203,7 +1203,7 @@
 u_set(void *ptr, PyObject *value, Py_ssize_t size)
 {
 	Py_ssize_t len;
-	if (PyString_Check(value)) {
+	if (PyBytes_Check(value)) {
 		value = PyUnicode_FromEncodedObject(value,
 						    conversion_mode_encoding,
 						    conversion_mode_errors);
@@ -1278,7 +1278,7 @@
 	/* It's easier to calculate in characters than in bytes */
 	length /= sizeof(wchar_t);
 
-	if (PyString_Check(value)) {
+	if (PyBytes_Check(value)) {
 		value = PyUnicode_FromEncodedObject(value,
 						    conversion_mode_encoding,
 						    conversion_mode_errors);
@@ -1334,8 +1334,8 @@
 						  conversion_mode_errors);
 		if (value == NULL)
 			return NULL;
-		assert(PyString_Check(value));
-	} else if(PyString_Check(value)) {
+		assert(PyBytes_Check(value));
+	} else if(PyBytes_Check(value)) {
 		Py_INCREF(value);
 	} else {
 		PyErr_Format(PyExc_TypeError,
@@ -1344,7 +1344,7 @@
 		return NULL;
 	}
 
-	data = PyString_AS_STRING(value);
+	data = PyBytes_AS_STRING(value);
 	if (!data)
 		return NULL;
 	size = strlen(data); /* XXX Why not Py_SIZE(value)? */
@@ -1375,8 +1375,8 @@
 		Py_INCREF(value);
 		return value;
 	}
-	if (PyString_Check(value)) {
-		*(char **)ptr = PyString_AsString(value);
+	if (PyBytes_Check(value)) {
+		*(char **)ptr = PyBytes_AsString(value);
 		Py_INCREF(value);
 		return value;
 	} else if (PyUnicode_Check(value)) {
@@ -1385,7 +1385,7 @@
 							  conversion_mode_errors);
 		if (str == NULL)
 			return NULL;
-		*(char **)ptr = PyString_AS_STRING(str);
+		*(char **)ptr = PyBytes_AS_STRING(str);
 		return str;
 	} else if (PyLong_Check(value)) {
 #if SIZEOF_VOID_P == SIZEOF_LONG_LONG
@@ -1439,7 +1439,7 @@
 		Py_INCREF(Py_None);
 		return Py_None;
 	}
-	if (PyString_Check(value)) {
+	if (PyBytes_Check(value)) {
 		value = PyUnicode_FromEncodedObject(value,
 						    conversion_mode_encoding,
 						    conversion_mode_errors);
@@ -1522,7 +1522,7 @@
 	/* convert value into a PyUnicodeObject or NULL */
 	if (Py_None == value) {
 		value = NULL;
-	} else if (PyString_Check(value)) {
+	} else if (PyBytes_Check(value)) {
 		value = PyUnicode_FromEncodedObject(value,
 						    conversion_mode_encoding,
 						    conversion_mode_errors);

Modified: python/branches/py3k/Modules/_cursesmodule.c
==============================================================================
--- python/branches/py3k/Modules/_cursesmodule.c	(original)
+++ python/branches/py3k/Modules/_cursesmodule.c	Mon May 26 15:28:38 2008
@@ -203,9 +203,9 @@
     *ch = (chtype) PyLong_AsLongAndOverflow(obj, &overflow);
     if (overflow)
       return 0;
-  } else if(PyString_Check(obj) 
-	    && (PyString_Size(obj) == 1)) {
-    *ch = (chtype) *PyString_AsString(obj);
+  } else if(PyBytes_Check(obj) 
+	    && (PyBytes_Size(obj) == 1)) {
+    *ch = (chtype) *PyBytes_AsString(obj);
   } else if (PyUnicode_Check(obj) && PyUnicode_GetSize(obj) == 1) {
     *ch = (chtype) *PyUnicode_AS_UNICODE(obj);
   } else {
@@ -950,7 +950,7 @@
   }
   if (rtn2 == ERR)
     rtn[0] = 0;
-  return PyString_FromString(rtn);
+  return PyBytes_FromString(rtn);
 }
 
 static PyObject *
@@ -1102,7 +1102,7 @@
   }
   if (rtn2 == ERR)
     rtn[0] = 0;
-  return PyString_FromString(rtn);
+  return PyBytes_FromString(rtn);
 }
 
 static PyObject *
@@ -1791,7 +1791,7 @@
 
   ch = erasechar();
 
-  return PyString_FromStringAndSize(&ch, 1);
+  return PyBytes_FromStringAndSize(&ch, 1);
 }
 
 static PyObject *
@@ -1869,7 +1869,7 @@
     remove(fn);
     return NULL;
   }
-  if (!PyString_Check(data)) {
+  if (!PyBytes_Check(data)) {
     PyErr_Format(PyExc_TypeError,
                  "f.read() returned %.100s instead of bytes",
                  data->ob_type->tp_name);
@@ -1878,7 +1878,7 @@
     remove(fn);
     return NULL;
   }
-  fwrite(PyString_AS_STRING(data), 1, PyString_GET_SIZE(data), fp);
+  fwrite(PyBytes_AS_STRING(data), 1, PyBytes_GET_SIZE(data), fp);
   Py_DECREF(data);
   fseek(fp, 0, 0);
   win = getwin(fp);
@@ -2175,7 +2175,7 @@
   }
   knp = keyname(ch);
 
-  return PyString_FromString((knp == NULL) ? "" : (char *)knp);
+  return PyBytes_FromString((knp == NULL) ? "" : (char *)knp);
 }
 #endif
 
@@ -2186,7 +2186,7 @@
 
   ch = killchar();  
 
-  return PyString_FromStringAndSize(&ch, 1);  
+  return PyBytes_FromStringAndSize(&ch, 1);  
 }  
 
 static PyObject *
@@ -2557,7 +2557,7 @@
 		Py_INCREF(Py_None);
 		return Py_None;
 	}
-	return PyString_FromString( capname );
+	return PyBytes_FromString( capname );
 }
 
 static PyObject *
@@ -2581,7 +2581,7 @@
   		return NULL;
 	}
 
-	return PyString_FromString(result);
+	return PyBytes_FromString(result);
 }
 
 static PyObject *
@@ -2611,7 +2611,7 @@
     return NULL;
   }
 
-  return PyString_FromString(unctrl(ch));
+  return PyBytes_FromString(unctrl(ch));
 }
 
 static PyObject *
@@ -2806,7 +2806,7 @@
 	PyDict_SetItemString(d, "error", PyCursesError);
 
 	/* Make the version available */
-	v = PyString_FromString(PyCursesVersion);
+	v = PyBytes_FromString(PyCursesVersion);
 	PyDict_SetItemString(d, "version", v);
 	PyDict_SetItemString(d, "__version__", v);
 	Py_DECREF(v);

Modified: python/branches/py3k/Modules/_dbmmodule.c
==============================================================================
--- python/branches/py3k/Modules/_dbmmodule.c	(original)
+++ python/branches/py3k/Modules/_dbmmodule.c	Mon May 26 15:28:38 2008
@@ -219,14 +219,14 @@
 		if (arg == NULL)
 			return -1;
 	}
-	if (!PyString_Check(arg)) {
+	if (!PyBytes_Check(arg)) {
 		PyErr_Format(PyExc_TypeError,
 			     "dbm key must be string, not %.100s",
 			     arg->ob_type->tp_name);
 		return -1;
 	}
-	key.dptr = PyString_AS_STRING(arg);
-	key.dsize = PyString_GET_SIZE(arg);
+	key.dptr = PyBytes_AS_STRING(arg);
+	key.dsize = PyBytes_GET_SIZE(arg);
 	val = dbm_fetch(dp->di_dbm, key);
 	return val.dptr != NULL;
 }

Modified: python/branches/py3k/Modules/_elementtree.c
==============================================================================
--- python/branches/py3k/Modules/_elementtree.c	(original)
+++ python/branches/py3k/Modules/_elementtree.c	Mon May 26 15:28:38 2008
@@ -152,7 +152,7 @@
     switch (PyList_GET_SIZE(list)) {
     case 0:
         Py_DECREF(list);
-        return PyString_FromString("");
+        return PyBytes_FromString("");
     case 1:
         result = PyList_GET_ITEM(list, 0);
         Py_INCREF(result);
@@ -725,9 +725,9 @@
         }
         return 0;
     }
-    if (PyString_Check(tag)) {
-        char *p = PyString_AS_STRING(tag);
-        for (i = 0; i < PyString_GET_SIZE(tag); i++) {
+    if (PyBytes_Check(tag)) {
+        char *p = PyBytes_AS_STRING(tag);
+        for (i = 0; i < PyBytes_GET_SIZE(tag); i++) {
             if (p[i] == '{')
                 check = 0;
             else if (p[i] == '}')
@@ -795,7 +795,7 @@
         if (Element_CheckExact(item) && !PyObject_Compare(item->tag, tag)) {
             PyObject* text = element_get_text(item);
             if (text == Py_None)
-                return PyString_FromString("");
+                return PyBytes_FromString("");
             Py_XINCREF(text);
             return text;
         }
@@ -1584,14 +1584,14 @@
         Py_INCREF(data); self->data = data;
     } else {
         /* more than one item; use a list to collect items */
-        if (PyString_CheckExact(self->data) && Py_REFCNT(self->data) == 1 &&
-            PyString_CheckExact(data) && PyString_GET_SIZE(data) == 1) {
+        if (PyBytes_CheckExact(self->data) && Py_REFCNT(self->data) == 1 &&
+            PyBytes_CheckExact(data) && PyBytes_GET_SIZE(data) == 1) {
             /* expat often generates single character data sections; handle
                the most common case by resizing the existing string... */
-            Py_ssize_t size = PyString_GET_SIZE(self->data);
-            if (_PyString_Resize(&self->data, size + 1) < 0)
+            Py_ssize_t size = PyBytes_GET_SIZE(self->data);
+            if (_PyBytes_Resize(&self->data, size + 1) < 0)
                 return NULL;
-            PyString_AS_STRING(self->data)[size] = PyString_AS_STRING(data)[0];
+            PyBytes_AS_STRING(self->data)[size] = PyBytes_AS_STRING(data)[0];
         } else if (PyList_CheckExact(self->data)) {
             if (PyList_Append(self->data, data) < 0)
                 return NULL;
@@ -1848,7 +1848,7 @@
     PyObject* value;
 
     /* look the 'raw' name up in the names dictionary */
-    key = PyString_FromStringAndSize(string, size);
+    key = PyBytes_FromStringAndSize(string, size);
     if (!key)
         return NULL;
 
@@ -1870,8 +1870,8 @@
                 break;
         if (i != size) {
             /* convert to universal name */
-            tag = PyString_FromStringAndSize(NULL, size+1);
-            p = PyString_AS_STRING(tag);
+            tag = PyBytes_FromStringAndSize(NULL, size+1);
+            p = PyBytes_AS_STRING(tag);
             p[0] = '{';
             memcpy(p+1, string, size);
             size++;
@@ -1882,7 +1882,7 @@
         }
         
         /* decode universal name */
-        p = PyString_AS_STRING(tag);
+        p = PyBytes_AS_STRING(tag);
         value = PyUnicode_DecodeUTF8(p, size, "strict");
         Py_DECREF(tag);
         if (!value) {
@@ -1935,7 +1935,7 @@
     } else {
         PyErr_Format(
             PyExc_SyntaxError, "undefined entity &%s;: line %ld, column %ld",
-            PyString_AS_STRING(key),
+            PyBytes_AS_STRING(key),
             EXPAT(GetErrorLineNumber)(self->parser),
             EXPAT(GetErrorColumnNumber)(self->parser)
             );
@@ -2362,13 +2362,13 @@
             return NULL;
         }
 
-        if (!PyString_CheckExact(buffer) || PyString_GET_SIZE(buffer) == 0) {
+        if (!PyBytes_CheckExact(buffer) || PyBytes_GET_SIZE(buffer) == 0) {
             Py_DECREF(buffer);
             break;
         }
 
         res = expat_parse(
-            self, PyString_AS_STRING(buffer), PyString_GET_SIZE(buffer), 0
+            self, PyBytes_AS_STRING(buffer), PyBytes_GET_SIZE(buffer), 0
             );
 
         Py_DECREF(buffer);
@@ -2430,7 +2430,7 @@
 
     if (event_set == Py_None) {
         /* default is "end" only */
-        target->end_event_obj = PyString_FromString("end");
+        target->end_event_obj = PyBytes_FromString("end");
         Py_RETURN_NONE;
     }
 
@@ -2440,9 +2440,9 @@
     for (i = 0; i < PyTuple_GET_SIZE(event_set); i++) {
         PyObject* item = PyTuple_GET_ITEM(event_set, i);
         char* event;
-        if (!PyString_Check(item))
+        if (!PyBytes_Check(item))
             goto error;
-        event = PyString_AS_STRING(item);
+        event = PyBytes_AS_STRING(item);
         if (strcmp(event, "start") == 0) {
             Py_INCREF(item);
             target->start_event_obj = item;
@@ -2514,7 +2514,7 @@
         char buffer[100];
         sprintf(buffer, "Expat %d.%d.%d", XML_MAJOR_VERSION,
                 XML_MINOR_VERSION, XML_MICRO_VERSION);
-        return PyString_FromString(buffer);
+        return PyBytes_FromString(buffer);
     } else {
         PyErr_SetString(PyExc_AttributeError, name);
         return NULL;

Modified: python/branches/py3k/Modules/_fileio.c
==============================================================================
--- python/branches/py3k/Modules/_fileio.c	(original)
+++ python/branches/py3k/Modules/_fileio.c	Mon May 26 15:28:38 2008
@@ -392,14 +392,14 @@
 	Py_ssize_t total = 0;
 	int n;
 
-	result = PyString_FromStringAndSize(NULL, DEFAULT_BUFFER_SIZE);
+	result = PyBytes_FromStringAndSize(NULL, DEFAULT_BUFFER_SIZE);
 	if (result == NULL)
 		return NULL;
 
 	while (1) {
 		Py_ssize_t newsize = total + DEFAULT_BUFFER_SIZE;
-		if (PyString_GET_SIZE(result) < newsize) {
-			if (_PyString_Resize(&result, newsize) < 0) {
+		if (PyBytes_GET_SIZE(result) < newsize) {
+			if (_PyBytes_Resize(&result, newsize) < 0) {
 				if (total == 0) {
 					Py_DECREF(result);
 					return NULL;
@@ -411,7 +411,7 @@
 		Py_BEGIN_ALLOW_THREADS
 		errno = 0;
 		n = read(self->fd,
-			 PyString_AS_STRING(result) + total,
+			 PyBytes_AS_STRING(result) + total,
 			 newsize - total);
 		Py_END_ALLOW_THREADS
 		if (n == 0)
@@ -430,8 +430,8 @@
 		total += n;
 	}
 
-	if (PyString_GET_SIZE(result) > total) {
-		if (_PyString_Resize(&result, total) < 0) {
+	if (PyBytes_GET_SIZE(result) > total) {
+		if (_PyBytes_Resize(&result, total) < 0) {
 			/* This should never happen, but just in case */
 			Py_DECREF(result);
 			return NULL;
@@ -460,10 +460,10 @@
 		return fileio_readall(self);
 	}
 
-	bytes = PyString_FromStringAndSize(NULL, size);
+	bytes = PyBytes_FromStringAndSize(NULL, size);
 	if (bytes == NULL)
 		return NULL;
-	ptr = PyString_AS_STRING(bytes);
+	ptr = PyBytes_AS_STRING(bytes);
 
 	Py_BEGIN_ALLOW_THREADS
 	errno = 0;
@@ -478,7 +478,7 @@
 	}
 
 	if (n != size) {
-		if (_PyString_Resize(&bytes, n) < 0) {
+		if (_PyBytes_Resize(&bytes, n) < 0) {
 			Py_DECREF(bytes);
 			return NULL;
 		}

Modified: python/branches/py3k/Modules/_gdbmmodule.c
==============================================================================
--- python/branches/py3k/Modules/_gdbmmodule.c	(original)
+++ python/branches/py3k/Modules/_gdbmmodule.c	Mon May 26 15:28:38 2008
@@ -130,7 +130,7 @@
         PyErr_SetObject(PyExc_KeyError, key);
         return NULL;
     }
-    v = PyString_FromStringAndSize(drec.dptr, drec.dsize);
+    v = PyBytes_FromStringAndSize(drec.dptr, drec.dsize);
     free(drec.dptr);
     return v;
 }
@@ -220,7 +220,7 @@
 
     key = gdbm_firstkey(dp->di_dbm);
     while (key.dptr) {
-        item = PyString_FromStringAndSize(key.dptr, key.dsize);
+        item = PyBytes_FromStringAndSize(key.dptr, key.dsize);
         if (item == NULL) {
             free(key.dptr);
             Py_DECREF(v);
@@ -251,14 +251,14 @@
 			"GDBM object has already been closed");
 	return -1;
     }
-    if (!PyString_Check(arg)) {
+    if (!PyBytes_Check(arg)) {
 	PyErr_Format(PyExc_TypeError,
 		     "gdbm key must be bytes, not %.100s",
 		     arg->ob_type->tp_name);
 	return -1;
     }
-    key.dptr = PyString_AS_STRING(arg);
-    key.dsize = PyString_GET_SIZE(arg);
+    key.dptr = PyBytes_AS_STRING(arg);
+    key.dsize = PyBytes_GET_SIZE(arg);
     return gdbm_exists(dp->di_dbm, key);
 }
 
@@ -291,7 +291,7 @@
     check_dbmobject_open(dp);
     key = gdbm_firstkey(dp->di_dbm);
     if (key.dptr) {
-        v = PyString_FromStringAndSize(key.dptr, key.dsize);
+        v = PyBytes_FromStringAndSize(key.dptr, key.dsize);
         free(key.dptr);
         return v;
     }
@@ -323,7 +323,7 @@
     check_dbmobject_open(dp);
     nextkey = gdbm_nextkey(dp->di_dbm, key);
     if (nextkey.dptr) {
-        v = PyString_FromStringAndSize(nextkey.dptr, nextkey.dsize);
+        v = PyBytes_FromStringAndSize(nextkey.dptr, nextkey.dsize);
         free(nextkey.dptr);
         return v;
     }

Modified: python/branches/py3k/Modules/_hashopenssl.c
==============================================================================
--- python/branches/py3k/Modules/_hashopenssl.c	(original)
+++ python/branches/py3k/Modules/_hashopenssl.c	Mon May 26 15:28:38 2008
@@ -108,7 +108,7 @@
     digest_size = EVP_MD_CTX_size(&temp_ctx);
     EVP_DigestFinal(&temp_ctx, digest, NULL);
 
-    retval = PyString_FromStringAndSize((const char *)digest, digest_size);
+    retval = PyBytes_FromStringAndSize((const char *)digest, digest_size);
     EVP_MD_CTX_cleanup(&temp_ctx);
     return retval;
 }

Modified: python/branches/py3k/Modules/_json.c
==============================================================================
--- python/branches/py3k/Modules/_json.c	(original)
+++ python/branches/py3k/Modules/_json.c	Mon May 26 15:28:38 2008
@@ -70,11 +70,11 @@
     input_unicode = PyUnicode_AS_UNICODE(pystr);
     /* One char input can be up to 6 chars output, estimate 4 of these */
     output_size = 2 + (MIN_EXPANSION * 4) + input_chars;
-    rval = PyString_FromStringAndSize(NULL, output_size);
+    rval = PyBytes_FromStringAndSize(NULL, output_size);
     if (rval == NULL) {
         return NULL;
     }
-    output = PyString_AS_STRING(rval);
+    output = PyBytes_AS_STRING(rval);
     chars = 0;
     output[chars++] = '"';
     for (i = 0; i < input_chars; i++) {
@@ -92,14 +92,14 @@
             if (output_size > 2 + (input_chars * MAX_EXPANSION)) {
                 output_size = 2 + (input_chars * MAX_EXPANSION);
             }
-            if (_PyString_Resize(&rval, output_size) == -1) {
+            if (_PyBytes_Resize(&rval, output_size) == -1) {
                 return NULL;
             }
-            output = PyString_AS_STRING(rval);
+            output = PyBytes_AS_STRING(rval);
         }
     }
     output[chars++] = '"';
-    if (_PyString_Resize(&rval, chars) == -1) {
+    if (_PyBytes_Resize(&rval, chars) == -1) {
         return NULL;
     }
     return rval;
@@ -116,15 +116,15 @@
     char *output;
     char *input_str;
 
-    input_chars = PyString_GET_SIZE(pystr);
-    input_str = PyString_AS_STRING(pystr);
+    input_chars = PyBytes_GET_SIZE(pystr);
+    input_str = PyBytes_AS_STRING(pystr);
     /* One char input can be up to 6 chars output, estimate 4 of these */
     output_size = 2 + (MIN_EXPANSION * 4) + input_chars;
-    rval = PyString_FromStringAndSize(NULL, output_size);
+    rval = PyBytes_FromStringAndSize(NULL, output_size);
     if (rval == NULL) {
         return NULL;
     }
-    output = PyString_AS_STRING(rval);
+    output = PyBytes_AS_STRING(rval);
     chars = 0;
     output[chars++] = '"';
     for (i = 0; i < input_chars; i++) {
@@ -154,14 +154,14 @@
             if (output_size > 2 + (input_chars * MIN_EXPANSION)) {
                 output_size = 2 + (input_chars * MIN_EXPANSION);
             }
-            if (_PyString_Resize(&rval, output_size) == -1) {
+            if (_PyBytes_Resize(&rval, output_size) == -1) {
                 return NULL;
             }
-            output = PyString_AS_STRING(rval);
+            output = PyBytes_AS_STRING(rval);
         }
     }
     output[chars++] = '"';
-    if (_PyString_Resize(&rval, chars) == -1) {
+    if (_PyBytes_Resize(&rval, chars) == -1) {
         return NULL;
     }
     return rval;
@@ -227,10 +227,10 @@
 scanstring_str(PyObject *pystr, Py_ssize_t end, char *encoding, int strict)
 {
     PyObject *rval;
-    Py_ssize_t len = PyString_GET_SIZE(pystr);
+    Py_ssize_t len = PyBytes_GET_SIZE(pystr);
     Py_ssize_t begin = end - 1;
     Py_ssize_t next = begin;
-    char *buf = PyString_AS_STRING(pystr);
+    char *buf = PyBytes_AS_STRING(pystr);
     Py_buffer info;
     PyObject *chunks = PyList_New(0);
     if (chunks == NULL) {
@@ -560,7 +560,7 @@
     if (encoding == NULL) {
         encoding = DEFAULT_ENCODING;
     }
-    if (PyString_Check(pystr)) {
+    if (PyBytes_Check(pystr)) {
         return scanstring_str(pystr, end, encoding, strict);
     }
     else if (PyUnicode_Check(pystr)) {
@@ -582,7 +582,7 @@
 {
     PyObject *rval;
     /* METH_O */
-    if (PyString_Check(pystr)) {
+    if (PyBytes_Check(pystr)) {
         rval = ascii_escape_str(pystr);
     }
     else if (PyUnicode_Check(pystr)) {
@@ -594,8 +594,8 @@
                      Py_TYPE(pystr)->tp_name);
         return NULL;
     }
-    if (PyString_Check(rval)) {
-        PyObject *urval = PyUnicode_DecodeASCII(PyString_AS_STRING(rval), PyString_GET_SIZE(rval), NULL);
+    if (PyBytes_Check(rval)) {
+        PyObject *urval = PyUnicode_DecodeASCII(PyBytes_AS_STRING(rval), PyBytes_GET_SIZE(rval), NULL);
         Py_DECREF(rval);
         return urval;
     }

Modified: python/branches/py3k/Modules/_sqlite/connection.c
==============================================================================
--- python/branches/py3k/Modules/_sqlite/connection.c	(original)
+++ python/branches/py3k/Modules/_sqlite/connection.c	Mon May 26 15:28:38 2008
@@ -483,7 +483,7 @@
                 break;
             case SQLITE_BLOB:
                 buflen = sqlite3_value_bytes(cur_value);
-                cur_py_value = PyString_FromStringAndSize(
+                cur_py_value = PyBytes_FromStringAndSize(
                     sqlite3_value_blob(cur_value), buflen);
                 break;
             case SQLITE_NULL:

Modified: python/branches/py3k/Modules/_sqlite/connection.h
==============================================================================
--- python/branches/py3k/Modules/_sqlite/connection.h	(original)
+++ python/branches/py3k/Modules/_sqlite/connection.h	Mon May 26 15:28:38 2008
@@ -80,7 +80,7 @@
     /* Determines how bytestrings from SQLite are converted to Python objects:
      * - PyUnicode_Type:        Python Unicode objects are constructed from UTF-8 bytestrings
      * - OptimizedUnicode:      Like before, but for ASCII data, only PyStrings are created.
-     * - PyString_Type:         PyStrings are created as-is.
+     * - PyBytes_Type:         PyStrings are created as-is.
      * - Any custom callable:   Any object returned from the callable called with the bytestring
      *                          as single parameter.
      */

Modified: python/branches/py3k/Modules/_sqlite/cursor.c
==============================================================================
--- python/branches/py3k/Modules/_sqlite/cursor.c	(original)
+++ python/branches/py3k/Modules/_sqlite/cursor.c	Mon May 26 15:28:38 2008
@@ -311,7 +311,7 @@
                 Py_INCREF(Py_None);
                 converted = Py_None;
             } else {
-                item = PyString_FromStringAndSize(val_str, nbytes);
+                item = PyBytes_FromStringAndSize(val_str, nbytes);
                 if (!item) {
                     return NULL;
                 }
@@ -366,8 +366,8 @@
                             Py_DECREF(buf_bytes);
                         }
                     }
-                } else if (self->connection->text_factory == (PyObject*)&PyString_Type) {
-                    converted = PyString_FromString(val_str);
+                } else if (self->connection->text_factory == (PyObject*)&PyBytes_Type) {
+                    converted = PyBytes_FromString(val_str);
                 } else if (self->connection->text_factory == (PyObject*)&PyByteArray_Type) {
                     converted = PyByteArray_FromStringAndSize(val_str, strlen(val_str));
                 } else {
@@ -376,7 +376,7 @@
             } else {
                 /* coltype == SQLITE_BLOB */
                 nbytes = sqlite3_column_bytes(self->statement->st, i);
-                buffer = PyString_FromStringAndSize(
+                buffer = PyBytes_FromStringAndSize(
                     sqlite3_column_blob(self->statement->st, i), nbytes);
                 if (!buffer) {
                     break;

Modified: python/branches/py3k/Modules/_sqlite/statement.c
==============================================================================
--- python/branches/py3k/Modules/_sqlite/statement.c	(original)
+++ python/branches/py3k/Modules/_sqlite/statement.c	Mon May 26 15:28:38 2008
@@ -120,7 +120,7 @@
     }
 
     if (paramtype == TYPE_STRING && !allow_8bit_chars) {
-        string = PyString_AS_STRING(parameter);
+        string = PyBytes_AS_STRING(parameter);
         for (c = string; *c != 0; c++) {
             if (*c & 0x80) {
                 PyErr_SetString(pysqlite_ProgrammingError, "You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings.");

Modified: python/branches/py3k/Modules/_sre.c
==============================================================================
--- python/branches/py3k/Modules/_sre.c	(original)
+++ python/branches/py3k/Modules/_sre.c	Mon May 26 15:28:38 2008
@@ -1714,7 +1714,7 @@
     /* determine character size */
     size = PyObject_Size(string);
 
-    if (PyString_Check(string) || bytes == size)
+    if (PyBytes_Check(string) || bytes == size)
         charsize = 1;
 #if defined(HAVE_UNICODE)
     else if (bytes == (Py_ssize_t) (size * sizeof(Py_UNICODE))) 

Modified: python/branches/py3k/Modules/_ssl.c
==============================================================================
--- python/branches/py3k/Modules/_ssl.c	(original)
+++ python/branches/py3k/Modules/_ssl.c	Mon May 26 15:28:38 2008
@@ -599,8 +599,8 @@
                 /*
                 fprintf(stderr, "RDN level %d, attribute %s: %s\n",
                         entry->set,
-                        PyString_AS_STRING(PyTuple_GET_ITEM(attr, 0)),
-                        PyString_AS_STRING(PyTuple_GET_ITEM(attr, 1)));
+                        PyBytes_AS_STRING(PyTuple_GET_ITEM(attr, 0)),
+                        PyBytes_AS_STRING(PyTuple_GET_ITEM(attr, 1)));
                 */
 		if (attr == NULL)
 			goto fail1;
@@ -987,7 +987,7 @@
 			return NULL;
 		}
                 /* this is actually an immutable bytes sequence */
-		retval = PyString_FromStringAndSize
+		retval = PyBytes_FromStringAndSize
                   ((const char *) bytes_buf, len);
 		OPENSSL_free(bytes_buf);
 		return retval;
@@ -1356,7 +1356,7 @@
 	}
   done:
 	if (!buf_passed) {
-		PyObject *res = PyString_FromStringAndSize(
+		PyObject *res = PyBytes_FromStringAndSize(
 			PyByteArray_AS_STRING(buf), count);
 		Py_DECREF(buf);
 		return res;

Modified: python/branches/py3k/Modules/_struct.c
==============================================================================
--- python/branches/py3k/Modules/_struct.c	(original)
+++ python/branches/py3k/Modules/_struct.c	Mon May 26 15:28:38 2008
@@ -439,7 +439,7 @@
 static PyObject *
 nu_char(const char *p, const formatdef *f)
 {
-	return PyString_FromStringAndSize(p, 1);
+	return PyBytes_FromStringAndSize(p, 1);
 }
 
 static PyObject *
@@ -608,12 +608,12 @@
 		if (v == NULL)
 			return -1;
 	}
-	if (!PyString_Check(v) || PyString_Size(v) != 1) {
+	if (!PyBytes_Check(v) || PyBytes_Size(v) != 1) {
 		PyErr_SetString(StructError,
 				"char format requires string of length 1");
 		return -1;
 	}
-	*p = *PyString_AsString(v);
+	*p = *PyBytes_AsString(v);
 	return 0;
 }
 
@@ -1333,7 +1333,7 @@
 	char c;
 	Py_ssize_t size, len, num, itemsize, x;
 
-	fmt = PyString_AS_STRING(self->s_format);
+	fmt = PyBytes_AS_STRING(self->s_format);
 
 	f = whichtable((char **)&fmt);
 
@@ -1478,7 +1478,7 @@
 		Py_INCREF(o_format);
 	}
 
-	if (!PyString_Check(o_format)) {
+	if (!PyBytes_Check(o_format)) {
 		Py_DECREF(o_format);
 		PyErr_Format(PyExc_TypeError,
 			     "Struct() argument 1 must be bytes, not %.200s",
@@ -1518,12 +1518,12 @@
 		const formatdef *e = code->fmtdef;
 		const char *res = startfrom + code->offset;
 		if (e->format == 's') {
-			v = PyString_FromStringAndSize(res, code->size);
+			v = PyBytes_FromStringAndSize(res, code->size);
 		} else if (e->format == 'p') {
 			Py_ssize_t n = *(unsigned char*)res;
 			if (n >= code->size)
 				n = code->size - 1;
-			v = PyString_FromStringAndSize(res + 1, n);
+			v = PyBytes_FromStringAndSize(res + 1, n);
 		} else {
 			v = e->unpack(res, e);
 		}
@@ -1645,15 +1645,15 @@
 				if (v == NULL)
 					return -1;
 			}
-			isstring = PyString_Check(v);
+			isstring = PyBytes_Check(v);
 			if (!isstring && !PyByteArray_Check(v)) {
 				PyErr_SetString(StructError,
 						"argument for 's' must be a string");
 				return -1;
 			}
 			if (isstring) {
-				n = PyString_GET_SIZE(v);
-				p = PyString_AS_STRING(v);
+				n = PyBytes_GET_SIZE(v);
+				p = PyBytes_AS_STRING(v);
 			}
 			else {
 				n = PyByteArray_GET_SIZE(v);
@@ -1671,15 +1671,15 @@
 				if (v == NULL)
 					return -1;
 			}
-			isstring = PyString_Check(v);
+			isstring = PyBytes_Check(v);
 			if (!isstring && !PyByteArray_Check(v)) {
 				PyErr_SetString(StructError,
 						"argument for 'p' must be a string");
 				return -1;
 			}
 			if (isstring) {
-				n = PyString_GET_SIZE(v);
-				p = PyString_AS_STRING(v);
+				n = PyBytes_GET_SIZE(v);
+				p = PyBytes_AS_STRING(v);
 			}
 			else {
 				n = PyByteArray_GET_SIZE(v);
@@ -1731,12 +1731,12 @@
 	}
 
 	/* Allocate a new string */
-	result = PyString_FromStringAndSize((char *)NULL, soself->s_size);
+	result = PyBytes_FromStringAndSize((char *)NULL, soself->s_size);
 	if (result == NULL)
 		return NULL;
 
 	/* Call the guts */
-	if ( s_pack_internal(soself, args, 0, PyString_AS_STRING(result)) != 0 ) {
+	if ( s_pack_internal(soself, args, 0, PyBytes_AS_STRING(result)) != 0 ) {
 		Py_DECREF(result);
 		return NULL;
 	}
@@ -2092,7 +2092,7 @@
 {
 	PyObject *ver, *m;
 
-	ver = PyString_FromString("0.2");
+	ver = PyBytes_FromString("0.2");
 	if (ver == NULL)
 		return;
 

Modified: python/branches/py3k/Modules/_tkinter.c
==============================================================================
--- python/branches/py3k/Modules/_tkinter.c	(original)
+++ python/branches/py3k/Modules/_tkinter.c	Mon May 26 15:28:38 2008
@@ -335,8 +335,8 @@
 static char *
 AsString(PyObject *value, PyObject *tmp)
 {
-	if (PyString_Check(value))
-		return PyString_AsString(value);
+	if (PyBytes_Check(value))
+		return PyBytes_AsString(value);
 	else if (PyUnicode_Check(value)) {
 		PyObject *v = PyUnicode_AsUTF8String(value);
 		if (v == NULL)
@@ -346,7 +346,7 @@
 			return NULL;
 		}
 		Py_DECREF(v);
-		return PyString_AsString(v);
+		return PyBytes_AsString(v);
 	}
 	else {
 		PyObject *v = PyObject_Str(value);
@@ -357,7 +357,7 @@
 			return NULL;
 		}
 		Py_DECREF(v);
-		return PyString_AsString(v);
+		return PyBytes_AsString(v);
 	}
 }
 
@@ -528,10 +528,10 @@
 			return result;
 		/* Fall through, returning arg. */
 	}
-	else if (PyString_Check(arg)) {
+	else if (PyBytes_Check(arg)) {
 		int argc;
 		char **argv;
-		char *list = PyString_AsString(arg);
+		char *list = PyBytes_AsString(arg);
 
 		if (Tcl_SplitList((Tcl_Interp *)NULL, list, &argc, &argv) != TCL_OK) {
 			Py_INCREF(arg);
@@ -539,7 +539,7 @@
 		}
 		Tcl_Free(FREECAST argv);
 		if (argc > 1)
-			return Split(PyString_AsString(arg));
+			return Split(PyBytes_AsString(arg));
 		/* Fall through, returning arg. */
 	}
 	Py_INCREF(arg);
@@ -866,9 +866,9 @@
 	long longVal;
 	int overflow;
 
-	if (PyString_Check(value))
-		return Tcl_NewStringObj(PyString_AS_STRING(value),
-					PyString_GET_SIZE(value));
+	if (PyBytes_Check(value))
+		return Tcl_NewStringObj(PyBytes_AS_STRING(value),
+					PyBytes_GET_SIZE(value));
 	else if (PyBool_Check(value))
 		return Tcl_NewBooleanObj(PyObject_IsTrue(value));
 	else if (PyLong_CheckExact(value) &&
@@ -961,7 +961,7 @@
 	if (value->typePtr == app->ByteArrayType) {
 		int size;
 		char *data = (char*)Tcl_GetByteArrayFromObj(value, &size);
-		return PyString_FromStringAndSize(data, size);
+		return PyBytes_FromStringAndSize(data, size);
 	}
 
 	if (value->typePtr == app->DoubleType) {
@@ -1419,8 +1419,8 @@
 varname_converter(PyObject *in, void *_out)
 {
 	char **out = (char**)_out;
-	if (PyString_Check(in)) {
-		*out = PyString_AsString(in);
+	if (PyBytes_Check(in)) {
+		*out = PyBytes_AsString(in);
 		return 1;
 	}
         if (PyUnicode_Check(in)) {
@@ -3071,7 +3071,7 @@
 						 Py_FileSystemDefaultEncoding, 
 						 NULL);
 		if (cexe)
-			Tcl_FindExecutable(PyString_AsString(cexe));
+			Tcl_FindExecutable(PyBytes_AsString(cexe));
 		Py_XDECREF(cexe);
 		Py_DECREF(uexe);
 	}

Modified: python/branches/py3k/Modules/arraymodule.c
==============================================================================
--- python/branches/py3k/Modules/arraymodule.c	(original)
+++ python/branches/py3k/Modules/arraymodule.c	Mon May 26 15:28:38 2008
@@ -1212,14 +1212,14 @@
 	if (b == NULL)
 		return NULL;
 
-	if (!PyString_Check(b)) {
+	if (!PyBytes_Check(b)) {
 		PyErr_SetString(PyExc_TypeError,
 				"read() didn't return bytes");
 		Py_DECREF(b);
 		return NULL;
 	}
 
-	if (PyString_GET_SIZE(b) != nbytes) {
+	if (PyBytes_GET_SIZE(b) != nbytes) {
 		PyErr_SetString(PyExc_EOFError,
 				"read() didn't return enough bytes");
 		Py_DECREF(b);
@@ -1263,7 +1263,7 @@
 		PyObject *bytes, *res;
 		if (i*BLOCKSIZE + size > nbytes)
 			size = nbytes - i*BLOCKSIZE;
-		bytes = PyString_FromStringAndSize(ptr, size);
+		bytes = PyBytes_FromStringAndSize(ptr, size);
 		if (bytes == NULL)
 			return NULL;
 		res = PyObject_CallMethod(f, "write", "O", bytes);
@@ -1394,7 +1394,7 @@
 static PyObject *
 array_tostring(arrayobject *self, PyObject *unused)
 {
-	return PyString_FromStringAndSize(self->ob_item,
+	return PyBytes_FromStringAndSize(self->ob_item,
                                          Py_SIZE(self) * self->ob_descr->itemsize);
 }
 
@@ -1856,7 +1856,7 @@
 
 	if (!(initial == NULL || PyList_Check(initial)
 	      || PyByteArray_Check(initial)
-	      || PyString_Check(initial)
+	      || PyBytes_Check(initial)
 	      || PyTuple_Check(initial)
 	      || ((c=='u') && PyUnicode_Check(initial)))) {
 		it = PyObject_GetIter(initial);
@@ -1902,7 +1902,7 @@
 				}
 			}
 			else if (initial != NULL && (PyByteArray_Check(initial) ||
-					   PyString_Check(initial))) {
+					   PyBytes_Check(initial))) {
 				PyObject *t_initial, *v;
 				t_initial = PyTuple_Pack(1, initial);
 				if (t_initial == NULL) {

Modified: python/branches/py3k/Modules/audioop.c
==============================================================================
--- python/branches/py3k/Modules/audioop.c	(original)
+++ python/branches/py3k/Modules/audioop.c	Mon May 26 15:28:38 2008
@@ -474,7 +474,7 @@
 
 	/* Passing a short** for an 's' argument is correct only
 	   if the string contents is aligned for interpretation
-	   as short[]. Due to the definition of PyStringObject,
+	   as short[]. Due to the definition of PyBytesObject,
 	   this is currently (Python 2.6) the case. */
         if ( !PyArg_ParseTuple(args, "s#s#:findfit",
 	                       (char**)&cp1, &len1, (char**)&cp2, &len2) )
@@ -759,10 +759,10 @@
                 return 0;
         }
     
-        rv = PyString_FromStringAndSize(NULL, len);
+        rv = PyBytes_FromStringAndSize(NULL, len);
         if ( rv == 0 )
                 return 0;
-        ncp = (signed char *)PyString_AsString(rv);
+        ncp = (signed char *)PyBytes_AsString(rv);
     
     
         for ( i=0; i < len; i += size ) {
@@ -801,10 +801,10 @@
                 return 0;
         }
     
-        rv = PyString_FromStringAndSize(NULL, len/2);
+        rv = PyBytes_FromStringAndSize(NULL, len/2);
         if ( rv == 0 )
                 return 0;
-        ncp = (signed char *)PyString_AsString(rv);
+        ncp = (signed char *)PyBytes_AsString(rv);
     
     
         for ( i=0; i < len; i += size*2 ) {
@@ -846,10 +846,10 @@
                 return 0;
         }
     
-        rv = PyString_FromStringAndSize(NULL, len*2);
+        rv = PyBytes_FromStringAndSize(NULL, len*2);
         if ( rv == 0 )
                 return 0;
-        ncp = (signed char *)PyString_AsString(rv);
+        ncp = (signed char *)PyBytes_AsString(rv);
     
     
         for ( i=0; i < len; i += size ) {
@@ -903,10 +903,10 @@
                 return 0;
         }
 
-        rv = PyString_FromStringAndSize(NULL, len1);
+        rv = PyBytes_FromStringAndSize(NULL, len1);
         if ( rv == 0 )
                 return 0;
-        ncp = (signed char *)PyString_AsString(rv);
+        ncp = (signed char *)PyBytes_AsString(rv);
 
         for ( i=0; i < len1; i += size ) {
                 if ( size == 1 )      val1 = (int)*CHARP(cp1, i);
@@ -949,10 +949,10 @@
                 return 0;
         }
     
-        rv = PyString_FromStringAndSize(NULL, len);
+        rv = PyBytes_FromStringAndSize(NULL, len);
         if ( rv == 0 )
                 return 0;
-        ncp = (signed char *)PyString_AsString(rv);
+        ncp = (signed char *)PyBytes_AsString(rv);
     
     
         for ( i=0; i < len; i += size ) {
@@ -985,10 +985,10 @@
                 return 0;
         }
     
-        rv = PyString_FromStringAndSize(NULL, len);
+        rv = PyBytes_FromStringAndSize(NULL, len);
         if ( rv == 0 )
                 return 0;
-        ncp = (unsigned char *)PyString_AsString(rv);
+        ncp = (unsigned char *)PyBytes_AsString(rv);
     
         for ( i=0; i < len; i += size ) {
                 if ( size == 1 )      val = ((int)*CHARP(cp, i)) << 8;
@@ -1023,10 +1023,10 @@
                 return 0;
         }
     
-        rv = PyString_FromStringAndSize(NULL, (len/size)*size2);
+        rv = PyBytes_FromStringAndSize(NULL, (len/size)*size2);
         if ( rv == 0 )
                 return 0;
-        ncp = (unsigned char *)PyString_AsString(rv);
+        ncp = (unsigned char *)PyBytes_AsString(rv);
     
         for ( i=0, j=0; i < len; i += size, j += size2 ) {
                 if ( size == 1 )      val = ((int)*CHARP(cp, i)) << 8;
@@ -1157,7 +1157,7 @@
                     nbytes / bytes_per_frame != ceiling)
                         str = NULL;
                 else
-                        str = PyString_FromStringAndSize(NULL, nbytes);
+                        str = PyBytes_FromStringAndSize(NULL, nbytes);
 
                 if (str == NULL) {
                         PyErr_SetString(PyExc_MemoryError,
@@ -1165,7 +1165,7 @@
                         goto exit;
                 }
         }
-        ncp = PyString_AsString(str);
+        ncp = PyBytes_AsString(str);
 
         for (;;) {
                 while (d < 0) {
@@ -1182,9 +1182,9 @@
                                         goto exit;
                                 /* We have checked before that the length
                                  * of the string fits into int. */
-                                len = (int)(ncp - PyString_AsString(str));
-				rv = PyString_FromStringAndSize
-					(PyString_AsString(str), len);
+                                len = (int)(ncp - PyBytes_AsString(str));
+				rv = PyBytes_FromStringAndSize
+					(PyBytes_AsString(str), len);
 				Py_DECREF(str);
 				str = rv;
 				if (str == NULL)
@@ -1254,10 +1254,10 @@
                 return 0;
         }
     
-        rv = PyString_FromStringAndSize(NULL, len/size);
+        rv = PyBytes_FromStringAndSize(NULL, len/size);
         if ( rv == 0 )
                 return 0;
-        ncp = (unsigned char *)PyString_AsString(rv);
+        ncp = (unsigned char *)PyBytes_AsString(rv);
     
         for ( i=0; i < len; i += size ) {
                 if ( size == 1 )      val = ((int)*CHARP(cp, i)) << 8;
@@ -1288,10 +1288,10 @@
                 return 0;
         }
     
-        rv = PyString_FromStringAndSize(NULL, len*size);
+        rv = PyBytes_FromStringAndSize(NULL, len*size);
         if ( rv == 0 )
                 return 0;
-        ncp = (signed char *)PyString_AsString(rv);
+        ncp = (signed char *)PyBytes_AsString(rv);
     
         for ( i=0; i < len*size; i += size ) {
                 cval = *cp++;
@@ -1322,10 +1322,10 @@
                 return 0;
         }
     
-        rv = PyString_FromStringAndSize(NULL, len/size);
+        rv = PyBytes_FromStringAndSize(NULL, len/size);
         if ( rv == 0 )
                 return 0;
-        ncp = (unsigned char *)PyString_AsString(rv);
+        ncp = (unsigned char *)PyBytes_AsString(rv);
     
         for ( i=0; i < len; i += size ) {
                 if ( size == 1 )      val = ((int)*CHARP(cp, i)) << 8;
@@ -1356,10 +1356,10 @@
                 return 0;
         }
     
-        rv = PyString_FromStringAndSize(NULL, len*size);
+        rv = PyBytes_FromStringAndSize(NULL, len*size);
         if ( rv == 0 )
                 return 0;
-        ncp = (signed char *)PyString_AsString(rv);
+        ncp = (signed char *)PyBytes_AsString(rv);
     
         for ( i=0; i < len*size; i += size ) {
                 cval = *cp++;
@@ -1392,10 +1392,10 @@
                 return 0;
         }
     
-        str = PyString_FromStringAndSize(NULL, len/(size*2));
+        str = PyBytes_FromStringAndSize(NULL, len/(size*2));
         if ( str == 0 )
                 return 0;
-        ncp = (signed char *)PyString_AsString(str);
+        ncp = (signed char *)PyBytes_AsString(str);
 
         /* Decode state, should have (value, step) */
         if ( state == Py_None ) {
@@ -1508,10 +1508,10 @@
         } else if ( !PyArg_ParseTuple(state, "ii", &valpred, &index) )
                 return 0;
     
-        str = PyString_FromStringAndSize(NULL, len*size*2);
+        str = PyBytes_FromStringAndSize(NULL, len*size*2);
         if ( str == 0 )
                 return 0;
-        ncp = (signed char *)PyString_AsString(str);
+        ncp = (signed char *)PyBytes_AsString(str);
 
         step = stepsizeTable[index];
         bufferstep = 0;

Modified: python/branches/py3k/Modules/binascii.c
==============================================================================
--- python/branches/py3k/Modules/binascii.c	(original)
+++ python/branches/py3k/Modules/binascii.c	Mon May 26 15:28:38 2008
@@ -203,9 +203,9 @@
 	ascii_len--;
 
 	/* Allocate the buffer */
-	if ( (rv=PyString_FromStringAndSize(NULL, bin_len)) == NULL )
+	if ( (rv=PyBytes_FromStringAndSize(NULL, bin_len)) == NULL )
 		return NULL;
-	bin_data = (unsigned char *)PyString_AS_STRING(rv);
+	bin_data = (unsigned char *)PyBytes_AS_STRING(rv);
 
 	for( ; bin_len > 0 ; ascii_len--, ascii_data++ ) {
 		/* XXX is it really best to add NULs if there's no more data */
@@ -280,9 +280,9 @@
 	}
 
 	/* We're lazy and allocate to much (fixed up later) */
-	if ( (rv=PyString_FromStringAndSize(NULL, bin_len*2+2)) == NULL )
+	if ( (rv=PyBytes_FromStringAndSize(NULL, bin_len*2+2)) == NULL )
 		return NULL;
-	ascii_data = (unsigned char *)PyString_AS_STRING(rv);
+	ascii_data = (unsigned char *)PyBytes_AS_STRING(rv);
 
 	/* Store the length */
 	*ascii_data++ = ' ' + (bin_len & 077);
@@ -304,9 +304,9 @@
 	}
 	*ascii_data++ = '\n';	/* Append a courtesy newline */
 
-	if (_PyString_Resize(&rv,
+	if (_PyBytes_Resize(&rv,
                            (ascii_data -
-                            (unsigned char *)PyString_AS_STRING(rv))) < 0) {
+                            (unsigned char *)PyBytes_AS_STRING(rv))) < 0) {
 		Py_DECREF(rv);
 		rv = NULL;
 	}
@@ -358,9 +358,9 @@
 	bin_len = ((ascii_len+3)/4)*3; /* Upper bound, corrected later */
 
 	/* Allocate the buffer */
-	if ( (rv=PyString_FromStringAndSize(NULL, bin_len)) == NULL )
+	if ( (rv=PyBytes_FromStringAndSize(NULL, bin_len)) == NULL )
 		return NULL;
-	bin_data = (unsigned char *)PyString_AS_STRING(rv);
+	bin_data = (unsigned char *)PyBytes_AS_STRING(rv);
 	bin_len = 0;
 
 	for( ; ascii_len > 0; ascii_len--, ascii_data++) {
@@ -419,17 +419,17 @@
 
 	/* And set string size correctly. If the result string is empty
 	** (because the input was all invalid) return the shared empty
-	** string instead; _PyString_Resize() won't do this for us.
+	** string instead; _PyBytes_Resize() won't do this for us.
 	*/
 	if (bin_len > 0) {
-		if (_PyString_Resize(&rv, bin_len) < 0) {
+		if (_PyBytes_Resize(&rv, bin_len) < 0) {
 			Py_DECREF(rv);
 			rv = NULL;
 		}
 	}
 	else {
 		Py_DECREF(rv);
-		rv = PyString_FromStringAndSize("", 0);
+		rv = PyBytes_FromStringAndSize("", 0);
 	}
 	return rv;
 }
@@ -456,9 +456,9 @@
 	/* We're lazy and allocate too much (fixed up later).
 	   "+3" leaves room for up to two pad characters and a trailing
 	   newline.  Note that 'b' gets encoded as 'Yg==\n' (1 in, 5 out). */
-	if ( (rv=PyString_FromStringAndSize(NULL, bin_len*2 + 3)) == NULL )
+	if ( (rv=PyBytes_FromStringAndSize(NULL, bin_len*2 + 3)) == NULL )
 		return NULL;
-	ascii_data = (unsigned char *)PyString_AS_STRING(rv);
+	ascii_data = (unsigned char *)PyBytes_AS_STRING(rv);
 
 	for( ; bin_len > 0 ; bin_len--, bin_data++ ) {
 		/* Shift the data into our buffer */
@@ -482,9 +482,9 @@
 	}
 	*ascii_data++ = '\n';	/* Append a courtesy newline */
 
-	if (_PyString_Resize(&rv,
+	if (_PyBytes_Resize(&rv,
 			   (ascii_data -
-			    (unsigned char *)PyString_AS_STRING(rv))) < 0) {
+			    (unsigned char *)PyBytes_AS_STRING(rv))) < 0) {
 		Py_DECREF(rv);
 		rv = NULL;
 	}
@@ -510,9 +510,9 @@
 	/* Allocate a string that is too big (fixed later) 
 	   Add two to the initial length to prevent interning which
 	   would preclude subsequent resizing.  */
-	if ( (rv=PyString_FromStringAndSize(NULL, len+2)) == NULL )
+	if ( (rv=PyBytes_FromStringAndSize(NULL, len+2)) == NULL )
 		return NULL;
-	bin_data = (unsigned char *)PyString_AS_STRING(rv);
+	bin_data = (unsigned char *)PyBytes_AS_STRING(rv);
 
 	for( ; len > 0 ; len--, ascii_data++ ) {
 		/* Get the byte and look it up */
@@ -546,9 +546,9 @@
 		Py_DECREF(rv);
 		return NULL;
 	}
-	if (_PyString_Resize(&rv,
+	if (_PyBytes_Resize(&rv,
 			   (bin_data -
-			    (unsigned char *)PyString_AS_STRING(rv))) < 0) {
+			    (unsigned char *)PyBytes_AS_STRING(rv))) < 0) {
 		Py_DECREF(rv);
 		rv = NULL;
 	}
@@ -575,9 +575,9 @@
 		return NULL;
 
 	/* Worst case: output is twice as big as input (fixed later) */
-	if ( (rv=PyString_FromStringAndSize(NULL, len*2+2)) == NULL )
+	if ( (rv=PyBytes_FromStringAndSize(NULL, len*2+2)) == NULL )
 		return NULL;
-	out_data = (unsigned char *)PyString_AS_STRING(rv);
+	out_data = (unsigned char *)PyBytes_AS_STRING(rv);
 
 	for( in=0; in<len; in++) {
 		ch = in_data[in];
@@ -603,9 +603,9 @@
 			}
 		}
 	}
-	if (_PyString_Resize(&rv,
+	if (_PyBytes_Resize(&rv,
 			   (out_data -
-			    (unsigned char *)PyString_AS_STRING(rv))) < 0) {
+			    (unsigned char *)PyBytes_AS_STRING(rv))) < 0) {
 		Py_DECREF(rv);
 		rv = NULL;
 	}
@@ -628,9 +628,9 @@
 		return NULL;
 
 	/* Allocate a buffer that is at least large enough */
-	if ( (rv=PyString_FromStringAndSize(NULL, len*2+2)) == NULL )
+	if ( (rv=PyBytes_FromStringAndSize(NULL, len*2+2)) == NULL )
 		return NULL;
-	ascii_data = (unsigned char *)PyString_AS_STRING(rv);
+	ascii_data = (unsigned char *)PyBytes_AS_STRING(rv);
 
 	for( ; len > 0 ; len--, bin_data++ ) {
 		/* Shift into our buffer, and output any 6bits ready */
@@ -647,9 +647,9 @@
 		leftchar <<= (6-leftbits);
 		*ascii_data++ = table_b2a_hqx[leftchar & 0x3f];
 	}
-	if (_PyString_Resize(&rv,
+	if (_PyBytes_Resize(&rv,
 			   (ascii_data -
-			    (unsigned char *)PyString_AS_STRING(rv))) < 0) {
+			    (unsigned char *)PyBytes_AS_STRING(rv))) < 0) {
 		Py_DECREF(rv);
 		rv = NULL;
 	}
@@ -671,14 +671,14 @@
 
 	/* Empty string is a special case */
 	if ( in_len == 0 )
-		return PyString_FromStringAndSize("", 0);
+		return PyBytes_FromStringAndSize("", 0);
 
 	/* Allocate a buffer of reasonable size. Resized when needed */
 	out_len = in_len*2;
-	if ( (rv=PyString_FromStringAndSize(NULL, out_len)) == NULL )
+	if ( (rv=PyBytes_FromStringAndSize(NULL, out_len)) == NULL )
 		return NULL;
 	out_len_left = out_len;
-	out_data = (unsigned char *)PyString_AS_STRING(rv);
+	out_data = (unsigned char *)PyBytes_AS_STRING(rv);
 
 	/*
 	** We need two macros here to get/put bytes and handle
@@ -697,9 +697,9 @@
 #define OUTBYTE(b) \
 	do { \
 		 if ( --out_len_left < 0 ) { \
-			  if (_PyString_Resize(&rv, 2*out_len) < 0) \
+			  if (_PyBytes_Resize(&rv, 2*out_len) < 0) \
 			    { Py_DECREF(rv); return NULL; } \
-			  out_data = (unsigned char *)PyString_AS_STRING(rv) \
+			  out_data = (unsigned char *)PyBytes_AS_STRING(rv) \
 								 + out_len; \
 			  out_len_left = out_len-1; \
 			  out_len = out_len * 2; \
@@ -747,9 +747,9 @@
 			OUTBYTE(in_byte);
 		}
 	}
-	if (_PyString_Resize(&rv,
+	if (_PyBytes_Resize(&rv,
 			   (out_data -
-			    (unsigned char *)PyString_AS_STRING(rv))) < 0) {
+			    (unsigned char *)PyBytes_AS_STRING(rv))) < 0) {
 		Py_DECREF(rv);
 		rv = NULL;
 	}
@@ -948,10 +948,10 @@
 	if (!PyArg_ParseTuple(args, "s#:b2a_hex", &argbuf, &arglen))
 		return NULL;
 
-	retval = PyString_FromStringAndSize(NULL, arglen*2);
+	retval = PyBytes_FromStringAndSize(NULL, arglen*2);
 	if (!retval)
 		return NULL;
-	retbuf = PyString_AS_STRING(retval);
+	retbuf = PyBytes_AS_STRING(retval);
 
 	/* make hex version of string, taken from shamodule.c */
 	for (i=j=0; i < arglen; i++) {
@@ -1008,10 +1008,10 @@
 		return NULL;
 	}
 
-	retval = PyString_FromStringAndSize(NULL, (arglen/2));
+	retval = PyBytes_FromStringAndSize(NULL, (arglen/2));
 	if (!retval)
 		return NULL;
-	retbuf = PyString_AS_STRING(retval);
+	retbuf = PyBytes_AS_STRING(retval);
 
 	for (i=j=0; i < arglen; i += 2) {
 		int top = to_int(Py_CHARMASK(argbuf[i]));
@@ -1123,7 +1123,7 @@
 			out++;
 		}
 	}
-	if ((rv = PyString_FromStringAndSize((char *)odata, out)) == NULL) {
+	if ((rv = PyBytes_FromStringAndSize((char *)odata, out)) == NULL) {
 		PyMem_Free(odata);
 		return NULL;
 	}
@@ -1323,7 +1323,7 @@
 			}
 		}
 	}
-	if ((rv = PyString_FromStringAndSize((char *)odata, out)) == NULL) {
+	if ((rv = PyBytes_FromStringAndSize((char *)odata, out)) == NULL) {
 		PyMem_Free(odata);
 		return NULL;
 	}

Modified: python/branches/py3k/Modules/bz2module.c
==============================================================================
--- python/branches/py3k/Modules/bz2module.c	(original)
+++ python/branches/py3k/Modules/bz2module.c	Mon May 26 15:28:38 2008
@@ -34,7 +34,7 @@
 #error "Large file support, but neither off_t nor fpos_t is large enough."
 #endif
 
-#define BUF(v) PyString_AS_STRING(v)
+#define BUF(v) PyBytes_AS_STRING(v)
 
 #define MODE_CLOSED   0
 #define MODE_READ     1
@@ -232,7 +232,7 @@
 	int bytes_read;
 
 	total_v_size = n > 0 ? n : 100;
-	v = PyString_FromStringAndSize((char *)NULL, total_v_size);
+	v = PyBytes_FromStringAndSize((char *)NULL, total_v_size);
 	if (v == NULL)
 		return NULL;
 
@@ -272,7 +272,7 @@
 			Py_DECREF(v);
 			return NULL;
 		}
-		if (_PyString_Resize(&v, total_v_size) < 0) {
+		if (_PyBytes_Resize(&v, total_v_size) < 0) {
 			return NULL;
 		}
 		buf = BUF(v) + used_v_size;
@@ -281,7 +281,7 @@
 
 	used_v_size = buf - BUF(v);
 	if (used_v_size != total_v_size) {
-		if (_PyString_Resize(&v, used_v_size) < 0) {
+		if (_PyBytes_Resize(&v, used_v_size) < 0) {
 			v = NULL;
 		}
 	}
@@ -338,10 +338,10 @@
 
 /* This is a hacked version of Python's
  * fileobject.c:readahead_get_line_skip(). */
-static PyStringObject *
+static PyBytesObject *
 Util_ReadAheadGetLineSkip(BZ2FileObject *f, int skip, int bufsize)
 {
-	PyStringObject* s;
+	PyBytesObject* s;
 	char *bufptr;
 	char *buf;
 	int len;
@@ -352,17 +352,17 @@
 
 	len = f->f_bufend - f->f_bufptr;
 	if (len == 0)
-		return (PyStringObject *)
-			PyString_FromStringAndSize(NULL, skip);
+		return (PyBytesObject *)
+			PyBytes_FromStringAndSize(NULL, skip);
 	bufptr = memchr(f->f_bufptr, '\n', len);
 	if (bufptr != NULL) {
 		bufptr++;			/* Count the '\n' */
 		len = bufptr - f->f_bufptr;
-		s = (PyStringObject *)
-			PyString_FromStringAndSize(NULL, skip+len);
+		s = (PyBytesObject *)
+			PyBytes_FromStringAndSize(NULL, skip+len);
 		if (s == NULL)
 			return NULL;
-		memcpy(PyString_AS_STRING(s)+skip, f->f_bufptr, len);
+		memcpy(PyBytes_AS_STRING(s)+skip, f->f_bufptr, len);
 		f->f_bufptr = bufptr;
 		if (bufptr == f->f_bufend)
 			Util_DropReadAhead(f);
@@ -376,7 +376,7 @@
 		        PyMem_Free(buf);
 			return NULL;
 		}
-		memcpy(PyString_AS_STRING(s)+skip, bufptr, len);
+		memcpy(PyBytes_AS_STRING(s)+skip, bufptr, len);
 		PyMem_Free(buf);
 	}
 	return s;
@@ -409,7 +409,7 @@
 		case MODE_READ:
 			break;
 		case MODE_READ_EOF:
-			ret = PyString_FromStringAndSize("", 0);
+			ret = PyBytes_FromStringAndSize("", 0);
 			goto cleanup;
 		case MODE_CLOSED:
 			PyErr_SetString(PyExc_ValueError,
@@ -431,7 +431,7 @@
 				"more than a Python string can hold");
 		goto cleanup;
 	}
-	ret = PyString_FromStringAndSize((char *)NULL, buffersize);
+	ret = PyBytes_FromStringAndSize((char *)NULL, buffersize);
 	if (ret == NULL || buffersize == 0)
 		goto cleanup;
 	bytesread = 0;
@@ -456,7 +456,7 @@
 		}
 		if (bytesrequested < 0) {
 			buffersize = Util_NewBufferSize(buffersize);
-			if (_PyString_Resize(&ret, buffersize) < 0) {
+			if (_PyBytes_Resize(&ret, buffersize) < 0) {
 				ret = NULL;
 				goto cleanup;
 			}
@@ -465,7 +465,7 @@
 		}
 	}
 	if (bytesread != buffersize) {
-		if (_PyString_Resize(&ret, bytesread) < 0) {
+		if (_PyBytes_Resize(&ret, bytesread) < 0) {
 			ret = NULL;
 		}
 	}
@@ -498,7 +498,7 @@
 		case MODE_READ:
 			break;
 		case MODE_READ_EOF:
-			ret = PyString_FromStringAndSize("", 0);
+			ret = PyBytes_FromStringAndSize("", 0);
 			goto cleanup;
 		case MODE_CLOSED:
 			PyErr_SetString(PyExc_ValueError,
@@ -511,7 +511,7 @@
 	}
 
 	if (sizehint == 0)
-		ret = PyString_FromStringAndSize("", 0);
+		ret = PyBytes_FromStringAndSize("", 0);
 	else
 		ret = Util_GetLine(self, (sizehint < 0) ? 0 : sizehint);
 
@@ -604,20 +604,20 @@
 			}
 			if (big_buffer == NULL) {
 				/* Create the big buffer */
-				big_buffer = PyString_FromStringAndSize(
+				big_buffer = PyBytes_FromStringAndSize(
 					NULL, buffersize);
 				if (big_buffer == NULL)
 					goto error;
-				buffer = PyString_AS_STRING(big_buffer);
+				buffer = PyBytes_AS_STRING(big_buffer);
 				memcpy(buffer, small_buffer, nfilled);
 			}
 			else {
 				/* Grow the big buffer */
-				if (_PyString_Resize(&big_buffer, buffersize) < 0){
+				if (_PyBytes_Resize(&big_buffer, buffersize) < 0){
 					big_buffer = NULL;
 					goto error;
 				}
-				buffer = PyString_AS_STRING(big_buffer);
+				buffer = PyBytes_AS_STRING(big_buffer);
 			}
 			continue;
 		}
@@ -626,7 +626,7 @@
 		while (p != NULL) {
 			/* Process complete lines */
 			p++;
-			line = PyString_FromStringAndSize(q, p-q);
+			line = PyBytes_FromStringAndSize(q, p-q);
 			if (line == NULL)
 				goto error;
 			err = PyList_Append(list, line);
@@ -649,7 +649,7 @@
 	}
 	if (nfilled != 0) {
 		/* Partial last line */
-		line = PyString_FromStringAndSize(buffer, nfilled);
+		line = PyBytes_FromStringAndSize(buffer, nfilled);
 		if (line == NULL)
 			goto error;
 		if (sizehint > 0) {
@@ -659,7 +659,7 @@
 				Py_DECREF(line);
 				goto error;
 			}
-			PyString_Concat(&line, rest);
+			PyBytes_Concat(&line, rest);
 			Py_DECREF(rest);
 			if (line == NULL)
 				goto error;
@@ -812,7 +812,7 @@
 		   could potentially execute Python code. */
 		for (i = 0; i < j; i++) {
 			PyObject *v = PyList_GET_ITEM(list, i);
-			if (!PyString_Check(v)) {
+			if (!PyBytes_Check(v)) {
 			    	const char *buffer;
 			    	Py_ssize_t len;
 				if (PyObject_AsCharBuffer(v, &buffer, &len)) {
@@ -823,7 +823,7 @@
 							"bytes objects");
 					goto error;
 				}
-				line = PyString_FromStringAndSize(buffer,
+				line = PyBytes_FromStringAndSize(buffer,
 								  len);
 				if (line == NULL)
 					goto error;
@@ -837,9 +837,9 @@
 		Py_BEGIN_ALLOW_THREADS
 		for (i = 0; i < j; i++) {
 		    	line = PyList_GET_ITEM(list, i);
-			len = PyString_GET_SIZE(line);
+			len = PyBytes_GET_SIZE(line);
 			BZ2_bzWrite (&bzerror, self->fp,
-				     PyString_AS_STRING(line), len);
+				     PyBytes_AS_STRING(line), len);
 			if (bzerror != BZ_OK) {
 				Py_BLOCK_THREADS
 				Util_CatchBZ2Error(bzerror);
@@ -1261,7 +1261,7 @@
 static PyObject *
 BZ2File_iternext(BZ2FileObject *self)
 {
-	PyStringObject* ret;
+	PyBytesObject* ret;
 	ACQUIRE_LOCK(self);
 	if (self->mode == MODE_CLOSED) {
 		PyErr_SetString(PyExc_ValueError,
@@ -1270,7 +1270,7 @@
 	}
 	ret = Util_ReadAheadGetLineSkip(self, 0, READAHEAD_BUFSIZE);
 	RELEASE_LOCK(self);
-	if (ret == NULL || PyString_GET_SIZE(ret) == 0) {
+	if (ret == NULL || PyBytes_GET_SIZE(ret) == 0) {
 		Py_XDECREF(ret);
 		return NULL;
 	}
@@ -1363,7 +1363,7 @@
 		return NULL;
 
 	if (datasize == 0)
-		return PyString_FromStringAndSize("", 0);
+		return PyBytes_FromStringAndSize("", 0);
 
 	ACQUIRE_LOCK(self);
 	if (!self->running) {
@@ -1372,7 +1372,7 @@
 		goto error;
 	}
 
-	ret = PyString_FromStringAndSize(NULL, bufsize);
+	ret = PyBytes_FromStringAndSize(NULL, bufsize);
 	if (!ret)
 		goto error;
 
@@ -1395,7 +1395,7 @@
 			break; /* no more input data */
 		if (bzs->avail_out == 0) {
 			bufsize = Util_NewBufferSize(bufsize);
-			if (_PyString_Resize(&ret, bufsize) < 0) {
+			if (_PyBytes_Resize(&ret, bufsize) < 0) {
 				BZ2_bzCompressEnd(bzs);
 				goto error;
 			}
@@ -1405,7 +1405,7 @@
 		}
 	}
 
-	if (_PyString_Resize(&ret,
+	if (_PyBytes_Resize(&ret,
 			   (Py_ssize_t)(BZS_TOTAL_OUT(bzs) - totalout)) < 0)
 		goto error;
 
@@ -1442,7 +1442,7 @@
 	}
 	self->running = 0;
 
-	ret = PyString_FromStringAndSize(NULL, bufsize);
+	ret = PyBytes_FromStringAndSize(NULL, bufsize);
 	if (!ret)
 		goto error;
 
@@ -1463,7 +1463,7 @@
 		}
 		if (bzs->avail_out == 0) {
 			bufsize = Util_NewBufferSize(bufsize);
-			if (_PyString_Resize(&ret, bufsize) < 0)
+			if (_PyBytes_Resize(&ret, bufsize) < 0)
 				goto error;
 			bzs->next_out = BUF(ret);
 			bzs->next_out = BUF(ret) + (BZS_TOTAL_OUT(bzs)
@@ -1473,7 +1473,7 @@
 	}
 
 	if (bzs->avail_out != 0) {
-		if (_PyString_Resize(&ret,
+		if (_PyBytes_Resize(&ret,
 			    (Py_ssize_t)(BZS_TOTAL_OUT(bzs) - totalout)) < 0)
 			goto error;
 	}
@@ -1658,7 +1658,7 @@
 		goto error;
 	}
 
-	ret = PyString_FromStringAndSize(NULL, bufsize);
+	ret = PyBytes_FromStringAndSize(NULL, bufsize);
 	if (!ret)
 		goto error;
 
@@ -1677,7 +1677,7 @@
 			if (bzs->avail_in != 0) {
 				Py_DECREF(self->unused_data);
 				self->unused_data =
-				    PyString_FromStringAndSize(bzs->next_in,
+				    PyBytes_FromStringAndSize(bzs->next_in,
 							       bzs->avail_in);
 			}
 			self->running = 0;
@@ -1691,7 +1691,7 @@
 			break; /* no more input data */
 		if (bzs->avail_out == 0) {
 			bufsize = Util_NewBufferSize(bufsize);
-			if (_PyString_Resize(&ret, bufsize) < 0) {
+			if (_PyBytes_Resize(&ret, bufsize) < 0) {
 				BZ2_bzDecompressEnd(bzs);
 				goto error;
 			}
@@ -1703,7 +1703,7 @@
 	}
 
 	if (bzs->avail_out != 0) {
-		if (_PyString_Resize(&ret,
+		if (_PyBytes_Resize(&ret,
 			    (Py_ssize_t)(BZS_TOTAL_OUT(bzs) - totalout)) < 0)
 			goto error;
 	}
@@ -1742,7 +1742,7 @@
 	}
 #endif
 
-	self->unused_data = PyString_FromStringAndSize("", 0);
+	self->unused_data = PyBytes_FromStringAndSize("", 0);
 	if (!self->unused_data)
 		goto error;
 
@@ -1875,7 +1875,7 @@
 	 * data in one shot. We will check it later anyway. */
 	bufsize = datasize + (datasize/100+1) + 600;
 
-	ret = PyString_FromStringAndSize(NULL, bufsize);
+	ret = PyBytes_FromStringAndSize(NULL, bufsize);
 	if (!ret)
 		return NULL;
 
@@ -1907,7 +1907,7 @@
 		}
 		if (bzs->avail_out == 0) {
 			bufsize = Util_NewBufferSize(bufsize);
-			if (_PyString_Resize(&ret, bufsize) < 0) {
+			if (_PyBytes_Resize(&ret, bufsize) < 0) {
 				BZ2_bzCompressEnd(bzs);
 				return NULL;
 			}
@@ -1917,7 +1917,7 @@
 	}
 
 	if (bzs->avail_out != 0) {
-		if (_PyString_Resize(&ret, (Py_ssize_t)BZS_TOTAL_OUT(bzs)) < 0) {
+		if (_PyBytes_Resize(&ret, (Py_ssize_t)BZS_TOTAL_OUT(bzs)) < 0) {
 			ret = NULL;
 		}
 	}
@@ -1948,9 +1948,9 @@
 		return NULL;
 
 	if (datasize == 0)
-		return PyString_FromStringAndSize("", 0);
+		return PyBytes_FromStringAndSize("", 0);
 
-	ret = PyString_FromStringAndSize(NULL, bufsize);
+	ret = PyBytes_FromStringAndSize(NULL, bufsize);
 	if (!ret)
 		return NULL;
 
@@ -1989,7 +1989,7 @@
 		}
 		if (bzs->avail_out == 0) {
 			bufsize = Util_NewBufferSize(bufsize);
-			if (_PyString_Resize(&ret, bufsize) < 0) {
+			if (_PyBytes_Resize(&ret, bufsize) < 0) {
 				BZ2_bzDecompressEnd(bzs);
 				return NULL;
 			}
@@ -1999,7 +1999,7 @@
 	}
 
 	if (bzs->avail_out != 0) {
-		if (_PyString_Resize(&ret, (Py_ssize_t)BZS_TOTAL_OUT(bzs)) < 0) {
+		if (_PyBytes_Resize(&ret, (Py_ssize_t)BZS_TOTAL_OUT(bzs)) < 0) {
 			ret = NULL;
 		}
 	}

Modified: python/branches/py3k/Modules/cStringIO.c
==============================================================================
--- python/branches/py3k/Modules/cStringIO.c	(original)
+++ python/branches/py3k/Modules/cStringIO.c	Mon May 26 15:28:38 2008
@@ -118,7 +118,7 @@
 static PyObject *
 IO_cgetval(PyObject *self) {
         if (!IO__opencheck(IOOOBJECT(self))) return NULL;
-        return PyString_FromStringAndSize(((IOobject*)self)->buf,
+        return PyBytes_FromStringAndSize(((IOobject*)self)->buf,
                                           ((IOobject*)self)->pos);
 }
 
@@ -136,7 +136,7 @@
         }
         else
                   s=self->string_size;
-        return PyString_FromStringAndSize(self->buf, s);
+        return PyBytes_FromStringAndSize(self->buf, s);
 }
 
 PyDoc_STRVAR(IO_isatty__doc__, "isatty(): always returns 0");
@@ -176,7 +176,7 @@
 
         if ( (n=IO_cread((PyObject*)self,&output,n)) < 0) return NULL;
 
-        return PyString_FromStringAndSize(output, n);
+        return PyBytes_FromStringAndSize(output, n);
 }
 
 PyDoc_STRVAR(IO_readline__doc__, "readline() -- Read one line");
@@ -214,7 +214,7 @@
                 n -= m;
                 self->pos -= m;
         }
-        return PyString_FromStringAndSize(output, n);
+        return PyBytes_FromStringAndSize(output, n);
 }
 
 PyDoc_STRVAR(IO_readlines__doc__, "readlines() -- Read all lines");
@@ -237,7 +237,7 @@
                         goto err;
 		if (n == 0)
 			break;
-		line = PyString_FromStringAndSize (output, n);
+		line = PyBytes_FromStringAndSize (output, n);
 		if (!line) 
                         goto err;
 		if (PyList_Append (result, line) == -1) {
@@ -314,7 +314,7 @@
 	next = IO_readline((IOobject *)self, NULL);
 	if (!next)
 		return NULL;
-	if (!PyString_GET_SIZE(next)) {
+	if (!PyBytes_GET_SIZE(next)) {
 		Py_DECREF(next);
 		PyErr_SetNone(PyExc_StopIteration);
 		return NULL;
@@ -455,7 +455,7 @@
 	while ((s = PyIter_Next(it)) != NULL) {
 		Py_ssize_t n;
 		char *c;
-		if (PyString_AsStringAndSize(s, &c, &n) == -1) {
+		if (PyBytes_AsStringAndSize(s, &c, &n) == -1) {
 			Py_DECREF(it);
 			Py_DECREF(s);
 			return NULL;

Modified: python/branches/py3k/Modules/cjkcodecs/multibytecodec.c
==============================================================================
--- python/branches/py3k/Modules/cjkcodecs/multibytecodec.c	(original)
+++ python/branches/py3k/Modules/cjkcodecs/multibytecodec.c	Mon May 26 15:28:38 2008
@@ -175,15 +175,15 @@
 	Py_ssize_t orgpos, orgsize;
 
 	orgpos = (Py_ssize_t)((char *)buf->outbuf -
-				PyString_AS_STRING(buf->outobj));
-	orgsize = PyString_GET_SIZE(buf->outobj);
-	if (_PyString_Resize(&buf->outobj, orgsize + (
+				PyBytes_AS_STRING(buf->outobj));
+	orgsize = PyBytes_GET_SIZE(buf->outobj);
+	if (_PyBytes_Resize(&buf->outobj, orgsize + (
 	    esize < (orgsize >> 1) ? (orgsize >> 1) | 1 : esize)) == -1)
 		return -1;
 
-	buf->outbuf = (unsigned char *)PyString_AS_STRING(buf->outobj) +orgpos;
-	buf->outbuf_end = (unsigned char *)PyString_AS_STRING(buf->outobj)
-		+ PyString_GET_SIZE(buf->outobj);
+	buf->outbuf = (unsigned char *)PyBytes_AS_STRING(buf->outobj) +orgpos;
+	buf->outbuf_end = (unsigned char *)PyBytes_AS_STRING(buf->outobj)
+		+ PyBytes_GET_SIZE(buf->outobj);
 
 	return 0;
 }
@@ -330,11 +330,11 @@
 			goto errorexit;
 	}
 
-        assert(PyString_Check(retstr));
-	retstrsize = PyString_GET_SIZE(retstr);
+        assert(PyBytes_Check(retstr));
+	retstrsize = PyBytes_GET_SIZE(retstr);
 	REQUIRE_ENCODEBUFFER(buf, retstrsize);
 
-	memcpy(buf->outbuf, PyString_AS_STRING(retstr), retstrsize);
+	memcpy(buf->outbuf, PyBytes_AS_STRING(retstr), retstrsize);
 	buf->outbuf += retstrsize;
 
 	newpos = PyLong_AsSsize_t(PyTuple_GET_ITEM(retobj, 1));
@@ -476,16 +476,16 @@
 	Py_ssize_t finalsize, r = 0;
 
 	if (datalen == 0)
-		return PyString_FromStringAndSize(NULL, 0);
+		return PyBytes_FromStringAndSize(NULL, 0);
 
 	buf.excobj = NULL;
 	buf.inbuf = buf.inbuf_top = *data;
 	buf.inbuf_end = buf.inbuf_top + datalen;
-	buf.outobj = PyString_FromStringAndSize(NULL, datalen * 2 + 16);
+	buf.outobj = PyBytes_FromStringAndSize(NULL, datalen * 2 + 16);
 	if (buf.outobj == NULL)
 		goto errorexit;
-	buf.outbuf = (unsigned char *)PyString_AS_STRING(buf.outobj);
-	buf.outbuf_end = buf.outbuf + PyString_GET_SIZE(buf.outobj);
+	buf.outbuf = (unsigned char *)PyBytes_AS_STRING(buf.outobj);
+	buf.outbuf_end = buf.outbuf + PyBytes_GET_SIZE(buf.outobj);
 
 	while (buf.inbuf < buf.inbuf_end) {
 		Py_ssize_t inleft, outleft;
@@ -520,10 +520,10 @@
 		}
 
 	finalsize = (Py_ssize_t)((char *)buf.outbuf -
-				 PyString_AS_STRING(buf.outobj));
+				 PyBytes_AS_STRING(buf.outobj));
 
-	if (finalsize != PyString_GET_SIZE(buf.outobj))
-		if (_PyString_Resize(&buf.outobj, finalsize) == -1)
+	if (finalsize != PyBytes_GET_SIZE(buf.outobj))
+		if (_PyBytes_Resize(&buf.outobj, finalsize) == -1)
 			goto errorexit;
 
 	Py_XDECREF(buf.excobj);
@@ -1230,7 +1230,7 @@
 		if (cres == NULL)
 			goto errorexit;
 
-		if (!PyString_Check(cres)) {
+		if (!PyBytes_Check(cres)) {
 			PyErr_Format(PyExc_TypeError,
                                      "stream function returned a "
                                      "non-bytes object (%.100s)",
@@ -1238,28 +1238,28 @@
 			goto errorexit;
 		}
 
- 		endoffile = (PyString_GET_SIZE(cres) == 0);
+ 		endoffile = (PyBytes_GET_SIZE(cres) == 0);
 
 		if (self->pendingsize > 0) {
 			PyObject *ctr;
 			char *ctrdata;
 
-			rsize = PyString_GET_SIZE(cres) + self->pendingsize;
-			ctr = PyString_FromStringAndSize(NULL, rsize);
+			rsize = PyBytes_GET_SIZE(cres) + self->pendingsize;
+			ctr = PyBytes_FromStringAndSize(NULL, rsize);
 			if (ctr == NULL)
 				goto errorexit;
-			ctrdata = PyString_AS_STRING(ctr);
+			ctrdata = PyBytes_AS_STRING(ctr);
 			memcpy(ctrdata, self->pending, self->pendingsize);
 			memcpy(ctrdata + self->pendingsize,
-				PyString_AS_STRING(cres),
-				PyString_GET_SIZE(cres));
+				PyBytes_AS_STRING(cres),
+				PyBytes_GET_SIZE(cres));
 			Py_DECREF(cres);
 			cres = ctr;
 			self->pendingsize = 0;
 		}
 
-		rsize = PyString_GET_SIZE(cres);
-		if (decoder_prepare_buffer(&buf, PyString_AS_STRING(cres),
+		rsize = PyBytes_GET_SIZE(cres);
+		if (decoder_prepare_buffer(&buf, PyBytes_AS_STRING(cres),
 					   rsize) != 0)
 			goto errorexit;
 
@@ -1603,8 +1603,8 @@
 	if (pwrt == NULL)
 		return NULL;
 
-        assert(PyString_Check(pwrt));
-	if (PyString_Size(pwrt) > 0) {
+        assert(PyBytes_Check(pwrt));
+	if (PyBytes_Size(pwrt) > 0) {
 		PyObject *wr;
 		wr = PyObject_CallMethod(self->stream, "write", "O", pwrt);
 		if (wr == NULL) {

Modified: python/branches/py3k/Modules/datetimemodule.c
==============================================================================
--- python/branches/py3k/Modules/datetimemodule.c	(original)
+++ python/branches/py3k/Modules/datetimemodule.c	Mon May 26 15:28:38 2008
@@ -1181,7 +1181,7 @@
 	else
 	    sprintf(freplacement, "%06d", 0);
 
-	return PyString_FromStringAndSize(freplacement, strlen(freplacement));
+	return PyBytes_FromStringAndSize(freplacement, strlen(freplacement));
 }
 
 /* I sure don't want to reproduce the strftime code from the time module,
@@ -1251,9 +1251,9 @@
 	 * is expensive, don't unless they're actually used.
 	 */
 	totalnew = flen + 1;	/* realistic if no %z/%Z */
-	newfmt = PyString_FromStringAndSize(NULL, totalnew);
+	newfmt = PyBytes_FromStringAndSize(NULL, totalnew);
 	if (newfmt == NULL) goto Done;
-	pnew = PyString_AsString(newfmt);
+	pnew = PyBytes_AsString(newfmt);
 	usednew = 0;
 
 	while ((ch = *pin++) != '\0') {
@@ -1273,7 +1273,7 @@
 				/* format utcoffset */
 				char buf[100];
 				PyObject *tzinfo = get_tzinfo_member(object);
-				zreplacement = PyString_FromStringAndSize("", 0);
+				zreplacement = PyBytes_FromStringAndSize("", 0);
 				if (zreplacement == NULL) goto Done;
 				if (tzinfo != Py_None && tzinfo != NULL) {
 					assert(tzinfoarg != NULL);
@@ -1285,15 +1285,15 @@
 						goto Done;
 					Py_DECREF(zreplacement);
 					zreplacement =
-					  PyString_FromStringAndSize(buf,
+					  PyBytes_FromStringAndSize(buf,
 								   strlen(buf));
 					if (zreplacement == NULL)
 						goto Done;
 				}
 			}
 			assert(zreplacement != NULL);
-			ptoappend = PyString_AS_STRING(zreplacement);
-			ntoappend = PyString_GET_SIZE(zreplacement);
+			ptoappend = PyBytes_AS_STRING(zreplacement);
+			ntoappend = PyBytes_GET_SIZE(zreplacement);
 		}
 		else if (ch == 'Z') {
 			/* format tzname */
@@ -1317,9 +1317,9 @@
 					goto Done;
 			}
 			assert(freplacement != NULL);
-			assert(PyString_Check(freplacement));
-			ptoappend = PyString_AS_STRING(freplacement);
-			ntoappend = PyString_GET_SIZE(freplacement);
+			assert(PyBytes_Check(freplacement));
+			ptoappend = PyBytes_AS_STRING(freplacement);
+			ntoappend = PyBytes_GET_SIZE(freplacement);
 		}
 		else {
 			/* percent followed by neither z nor Z */
@@ -1340,10 +1340,10 @@
  				PyErr_NoMemory();
  				goto Done;
  			}
- 			if (_PyString_Resize(&newfmt, bigger) < 0)
+ 			if (_PyBytes_Resize(&newfmt, bigger) < 0)
  				goto Done;
  			totalnew = bigger;
- 			pnew = PyString_AsString(newfmt) + usednew;
+ 			pnew = PyBytes_AsString(newfmt) + usednew;
  		}
 		memcpy(pnew, ptoappend, ntoappend);
 		pnew += ntoappend;
@@ -1351,14 +1351,14 @@
 		assert(usednew <= totalnew);
 	}  /* end while() */
 
-	if (_PyString_Resize(&newfmt, usednew) < 0)
+	if (_PyBytes_Resize(&newfmt, usednew) < 0)
 		goto Done;
 	{
 		PyObject *format;
 		PyObject *time = PyImport_ImportModuleNoBlock("time");
 		if (time == NULL)
 			goto Done;
-		format = PyUnicode_FromString(PyString_AS_STRING(newfmt));
+		format = PyUnicode_FromString(PyBytes_AS_STRING(newfmt));
 		if (format != NULL) {
 			result = PyObject_CallMethod(time, "strftime", "OO",
 						     format, timetuple);
@@ -2213,15 +2213,15 @@
 
 	/* Check for invocation from pickle with __getstate__ state */
 	if (PyTuple_GET_SIZE(args) == 1 &&
-	    PyString_Check(state = PyTuple_GET_ITEM(args, 0)) &&
-	    PyString_GET_SIZE(state) == _PyDateTime_DATE_DATASIZE &&
-	    MONTH_IS_SANE(PyString_AS_STRING(state)[2]))
+	    PyBytes_Check(state = PyTuple_GET_ITEM(args, 0)) &&
+	    PyBytes_GET_SIZE(state) == _PyDateTime_DATE_DATASIZE &&
+	    MONTH_IS_SANE(PyBytes_AS_STRING(state)[2]))
 	{
 	    	PyDateTime_Date *me;
 
 		me = (PyDateTime_Date *) (type->tp_alloc(type, 0));
 		if (me != NULL) {
-			char *pdata = PyString_AS_STRING(state);
+			char *pdata = PyBytes_AS_STRING(state);
 			memcpy(me->data, pdata, _PyDateTime_DATE_DATASIZE);
 			me->hashcode = -1;
 		}
@@ -2609,7 +2609,7 @@
 date_getstate(PyDateTime_Date *self)
 {
 	PyObject* field;
-	field = PyString_FromStringAndSize((char*)self->data,
+	field = PyBytes_FromStringAndSize((char*)self->data,
 					   _PyDateTime_DATE_DATASIZE);
 	return Py_BuildValue("(N)", field);
 }
@@ -3062,9 +3062,9 @@
 	/* Check for invocation from pickle with __getstate__ state */
 	if (PyTuple_GET_SIZE(args) >= 1 &&
 	    PyTuple_GET_SIZE(args) <= 2 &&
-	    PyString_Check(state = PyTuple_GET_ITEM(args, 0)) &&
-	    PyString_GET_SIZE(state) == _PyDateTime_TIME_DATASIZE &&
-	    ((unsigned char) (PyString_AS_STRING(state)[0])) < 24)
+	    PyBytes_Check(state = PyTuple_GET_ITEM(args, 0)) &&
+	    PyBytes_GET_SIZE(state) == _PyDateTime_TIME_DATASIZE &&
+	    ((unsigned char) (PyBytes_AS_STRING(state)[0])) < 24)
 	{
 		PyDateTime_Time *me;
 		char aware;
@@ -3080,7 +3080,7 @@
 		aware = (char)(tzinfo != Py_None);
 		me = (PyDateTime_Time *) (type->tp_alloc(type, aware));
 		if (me != NULL) {
-			char *pdata = PyString_AS_STRING(state);
+			char *pdata = PyBytes_AS_STRING(state);
 
 			memcpy(me->data, pdata, _PyDateTime_TIME_DATASIZE);
 			me->hashcode = -1;
@@ -3397,7 +3397,7 @@
 	PyObject *basestate;
 	PyObject *result = NULL;
 
-	basestate =  PyString_FromStringAndSize((char *)self->data,
+	basestate =  PyBytes_FromStringAndSize((char *)self->data,
 						_PyDateTime_TIME_DATASIZE);
 	if (basestate != NULL) {
 		if (! HASTZINFO(self) || self->tzinfo == Py_None)
@@ -3581,9 +3581,9 @@
 	/* Check for invocation from pickle with __getstate__ state */
 	if (PyTuple_GET_SIZE(args) >= 1 &&
 	    PyTuple_GET_SIZE(args) <= 2 &&
-	    PyString_Check(state = PyTuple_GET_ITEM(args, 0)) &&
-	    PyString_GET_SIZE(state) == _PyDateTime_DATETIME_DATASIZE &&
-	    MONTH_IS_SANE(PyString_AS_STRING(state)[2]))
+	    PyBytes_Check(state = PyTuple_GET_ITEM(args, 0)) &&
+	    PyBytes_GET_SIZE(state) == _PyDateTime_DATETIME_DATASIZE &&
+	    MONTH_IS_SANE(PyBytes_AS_STRING(state)[2]))
 	{
 		PyDateTime_DateTime *me;
 		char aware;
@@ -3599,7 +3599,7 @@
 		aware = (char)(tzinfo != Py_None);
 		me = (PyDateTime_DateTime *) (type->tp_alloc(type , aware));
 		if (me != NULL) {
-			char *pdata = PyString_AS_STRING(state);
+			char *pdata = PyBytes_AS_STRING(state);
 
 			memcpy(me->data, pdata, _PyDateTime_DATETIME_DATASIZE);
 			me->hashcode = -1;
@@ -4478,7 +4478,7 @@
 	PyObject *basestate;
 	PyObject *result = NULL;
 
-	basestate = PyString_FromStringAndSize((char *)self->data,
+	basestate = PyBytes_FromStringAndSize((char *)self->data,
 					       _PyDateTime_DATETIME_DATASIZE);
 	if (basestate != NULL) {
 		if (! HASTZINFO(self) || self->tzinfo == Py_None)

Modified: python/branches/py3k/Modules/fcntlmodule.c
==============================================================================
--- python/branches/py3k/Modules/fcntlmodule.c	(original)
+++ python/branches/py3k/Modules/fcntlmodule.c	Mon May 26 15:28:38 2008
@@ -55,7 +55,7 @@
 			PyErr_SetFromErrno(PyExc_IOError);
 			return NULL;
 		}
-		return PyString_FromStringAndSize(buf, len);
+		return PyBytes_FromStringAndSize(buf, len);
 	}
 
 	PyErr_Clear();
@@ -164,7 +164,7 @@
 			return PyLong_FromLong(ret);
 		}
 		else {
-			return PyString_FromStringAndSize(buf, len);
+			return PyBytes_FromStringAndSize(buf, len);
 		}
 	}
 
@@ -185,7 +185,7 @@
 			PyErr_SetFromErrno(PyExc_IOError);
 			return NULL;
 		}
-		return PyString_FromStringAndSize(buf, len);
+		return PyBytes_FromStringAndSize(buf, len);
 	}
 
 	PyErr_Clear();

Modified: python/branches/py3k/Modules/md5module.c
==============================================================================
--- python/branches/py3k/Modules/md5module.c	(original)
+++ python/branches/py3k/Modules/md5module.c	Mon May 26 15:28:38 2008
@@ -363,7 +363,7 @@
 
     temp = self->hash_state;
     md5_done(&temp, digest);
-    return PyString_FromStringAndSize((const char *)digest, MD5_DIGESTSIZE);
+    return PyBytes_FromStringAndSize((const char *)digest, MD5_DIGESTSIZE);
 }
 
 PyDoc_STRVAR(MD5_hexdigest__doc__,

Modified: python/branches/py3k/Modules/mmapmodule.c
==============================================================================
--- python/branches/py3k/Modules/mmapmodule.c	(original)
+++ python/branches/py3k/Modules/mmapmodule.c	Mon May 26 15:28:38 2008
@@ -708,9 +708,9 @@
 		}
 
 		if (slicelen <= 0)
-			return PyString_FromStringAndSize("", 0);
+			return PyBytes_FromStringAndSize("", 0);
 		else if (step == 1)
-			return PyString_FromStringAndSize(self->data + start,
+			return PyBytes_FromStringAndSize(self->data + start,
 							  slicelen);
 		else {
 			char *result_buf = (char *)PyMem_Malloc(slicelen);
@@ -723,7 +723,7 @@
 			     cur += step, i++) {
 			     	result_buf[i] = self->data[cur];
 			}
-			result = PyString_FromStringAndSize(result_buf,
+			result = PyBytes_FromStringAndSize(result_buf,
 							    slicelen);
 			PyMem_Free(result_buf);
 			return result;

Modified: python/branches/py3k/Modules/posixmodule.c
==============================================================================
--- python/branches/py3k/Modules/posixmodule.c	(original)
+++ python/branches/py3k/Modules/posixmodule.c	Mon May 26 15:28:38 2008
@@ -425,13 +425,13 @@
 
         rc = DosQueryExtLIBPATH(buffer, BEGIN_LIBPATH);
 	if (rc == NO_ERROR) { /* (not a type, envname is NOT 'BEGIN_LIBPATH') */
-            PyObject *v = PyString_FromString(buffer);
+            PyObject *v = PyBytes_FromString(buffer);
 	    PyDict_SetItemString(d, "BEGINLIBPATH", v);
             Py_DECREF(v);
         }
         rc = DosQueryExtLIBPATH(buffer, END_LIBPATH);
         if (rc == NO_ERROR) { /* (not a typo, envname is NOT 'END_LIBPATH') */
-            PyObject *v = PyString_FromString(buffer);
+            PyObject *v = PyBytes_FromString(buffer);
 	    PyDict_SetItemString(d, "ENDLIBPATH", v);
             Py_DECREF(v);
         }
@@ -2197,7 +2197,7 @@
 		/* Skip over . and .. */
 		if (strcmp(FileData.cFileName, ".") != 0 &&
 		    strcmp(FileData.cFileName, "..") != 0) {
-			v = PyString_FromString(FileData.cFileName);
+			v = PyBytes_FromString(FileData.cFileName);
 			if (v == NULL) {
 				Py_DECREF(d);
 				d = NULL;
@@ -2289,7 +2289,7 @@
             /* Leave Case of Name Alone -- In Native Form */
             /* (Removed Forced Lowercasing Code) */
 
-            v = PyString_FromString(namebuf);
+            v = PyBytes_FromString(namebuf);
             if (v == NULL) {
                 Py_DECREF(d);
                 d = NULL;
@@ -2340,7 +2340,7 @@
 		    (NAMLEN(ep) == 1 ||
 		     (ep->d_name[1] == '.' && NAMLEN(ep) == 2)))
 			continue;
-		v = PyString_FromStringAndSize(ep->d_name, NAMLEN(ep));
+		v = PyBytes_FromStringAndSize(ep->d_name, NAMLEN(ep));
 		if (v == NULL) {
 			Py_DECREF(d);
 			d = NULL;
@@ -2423,7 +2423,7 @@
 		return PyUnicode_Decode(outbuf, strlen(outbuf),
 			Py_FileSystemDefaultEncoding, NULL);
 	}
-	return PyString_FromString(outbuf);
+	return PyBytes_FromString(outbuf);
 } /* end of posix__getfullpathname */
 #endif /* MS_WINDOWS */
 
@@ -4445,7 +4445,7 @@
 		return posix_error_with_allocated_filename(path);
 
 	PyMem_Free(path);
-	v = PyString_FromStringAndSize(buf, n);
+	v = PyBytes_FromStringAndSize(buf, n);
 	if (arg_is_unicode) {
 		PyObject *w;
 
@@ -4849,18 +4849,18 @@
 		errno = EINVAL;
 		return posix_error();
 	}
-	buffer = PyString_FromStringAndSize((char *)NULL, size);
+	buffer = PyBytes_FromStringAndSize((char *)NULL, size);
 	if (buffer == NULL)
 		return NULL;
 	Py_BEGIN_ALLOW_THREADS
-	n = read(fd, PyString_AS_STRING(buffer), size);
+	n = read(fd, PyBytes_AS_STRING(buffer), size);
 	Py_END_ALLOW_THREADS
 	if (n < 0) {
 		Py_DECREF(buffer);
 		return posix_error();
 	}
 	if (n != size)
-		_PyString_Resize(&buffer, n);
+		_PyBytes_Resize(&buffer, n);
 	return buffer;
 }
 
@@ -5160,13 +5160,13 @@
 #endif
 	/* XXX This can leak memory -- not easy to fix :-( */
 	/* len includes space for a trailing \0; the size arg to
-	   PyString_FromStringAndSize does not count that */
+	   PyBytes_FromStringAndSize does not count that */
 #ifdef MS_WINDOWS
 	len = wcslen(s1) + wcslen(s2) + 2;
 	newstr = PyUnicode_FromUnicode(NULL, (int)len - 1);
 #else
 	len = strlen(s1) + strlen(s2) + 2;
-	newstr = PyString_FromStringAndSize(NULL, (int)len - 1);
+	newstr = PyBytes_FromStringAndSize(NULL, (int)len - 1);
 #endif
 	if (newstr == NULL)
 		return PyErr_NoMemory();
@@ -5179,7 +5179,7 @@
                 return NULL;
 	}
 #else
-	newenv = PyString_AS_STRING(newstr);
+	newenv = PyBytes_AS_STRING(newstr);
 	PyOS_snprintf(newenv, len, "%s=%s", s1, s2);
 	if (putenv(newenv)) {
                 Py_DECREF(newstr);
@@ -6667,11 +6667,11 @@
 	}
 
 	/* Allocate bytes */
-	result = PyString_FromStringAndSize(NULL, howMany);
+	result = PyBytes_FromStringAndSize(NULL, howMany);
 	if (result != NULL) {
 		/* Get random data */
 		if (! pCryptGenRandom(hCryptProv, howMany, (unsigned char*)
-				      PyString_AS_STRING(result))) {
+				      PyBytes_AS_STRING(result))) {
 			Py_DECREF(result);
 			return win32_error("CryptGenRandom", NULL);
 		}
@@ -6738,11 +6738,11 @@
 				    "negative argument not allowed");
 
 	/* Allocate bytes */
-	result = PyString_FromStringAndSize(NULL, howMany);
+	result = PyBytes_FromStringAndSize(NULL, howMany);
 	if (result != NULL) {
 		/* Get random data */
 		if (RAND_pseudo_bytes((unsigned char*)
-				      PyString_AS_STRING(result),
+				      PyBytes_AS_STRING(result),
 				      howMany) < 0) {
 			Py_DECREF(result);
 			return PyErr_Format(PyExc_ValueError,

Modified: python/branches/py3k/Modules/pyexpat.c
==============================================================================
--- python/branches/py3k/Modules/pyexpat.c	(original)
+++ python/branches/py3k/Modules/pyexpat.c	Mon May 26 15:28:38 2008
@@ -215,7 +215,7 @@
     PyObject *filename = NULL;
 
     if (handler_info[slot].tb_code == NULL) {
-        code = PyString_FromString("");
+        code = PyBytes_FromString("");
         if (code == NULL)
             goto failed;
         name = PyUnicode_FromString(func_name);
@@ -864,8 +864,8 @@
     if (str == NULL)
         goto finally;
 
-    if (PyString_Check(str))
-        ptr = PyString_AS_STRING(str);
+    if (PyBytes_Check(str))
+        ptr = PyBytes_AS_STRING(str);
     else if (PyByteArray_Check(str))
         ptr = PyByteArray_AS_STRING(str);
     else {
@@ -988,7 +988,7 @@
             = XML_GetInputContext(self->itself, &offset, &size);
 
         if (buffer != NULL)
-            return PyString_FromStringAndSize(buffer + offset,
+            return PyBytes_FromStringAndSize(buffer + offset,
                                               size - offset);
         else
             Py_RETURN_NONE;

Modified: python/branches/py3k/Modules/selectmodule.c
==============================================================================
--- python/branches/py3k/Modules/selectmodule.c	(original)
+++ python/branches/py3k/Modules/selectmodule.c	Mon May 26 15:28:38 2008
@@ -1216,7 +1216,7 @@
 		"data=0x%lx udata=%p>",
 		(unsigned long)(s->e.ident), s->e.filter, s->e.flags,
 		s->e.fflags, (long)(s->e.data), s->e.udata);
-	return PyString_FromString(buf);
+	return PyBytes_FromString(buf);
 }
 
 static int

Modified: python/branches/py3k/Modules/sha1module.c
==============================================================================
--- python/branches/py3k/Modules/sha1module.c	(original)
+++ python/branches/py3k/Modules/sha1module.c	Mon May 26 15:28:38 2008
@@ -339,7 +339,7 @@
 
     temp = self->hash_state;
     sha1_done(&temp, digest);
-    return PyString_FromStringAndSize((const char *)digest, SHA1_DIGESTSIZE);
+    return PyBytes_FromStringAndSize((const char *)digest, SHA1_DIGESTSIZE);
 }
 
 PyDoc_STRVAR(SHA1_hexdigest__doc__,

Modified: python/branches/py3k/Modules/sha256module.c
==============================================================================
--- python/branches/py3k/Modules/sha256module.c	(original)
+++ python/branches/py3k/Modules/sha256module.c	Mon May 26 15:28:38 2008
@@ -432,7 +432,7 @@
 
     SHAcopy(self, &temp);
     sha_final(digest, &temp);
-    return PyString_FromStringAndSize((const char *)digest, self->digestsize);
+    return PyBytes_FromStringAndSize((const char *)digest, self->digestsize);
 }
 
 PyDoc_STRVAR(SHA256_hexdigest__doc__,

Modified: python/branches/py3k/Modules/sha512module.c
==============================================================================
--- python/branches/py3k/Modules/sha512module.c	(original)
+++ python/branches/py3k/Modules/sha512module.c	Mon May 26 15:28:38 2008
@@ -498,7 +498,7 @@
 
     SHAcopy(self, &temp);
     sha512_final(digest, &temp);
-    return PyString_FromStringAndSize((const char *)digest, self->digestsize);
+    return PyBytes_FromStringAndSize((const char *)digest, self->digestsize);
 }
 
 PyDoc_STRVAR(SHA512_hexdigest__doc__,

Modified: python/branches/py3k/Modules/socketmodule.c
==============================================================================
--- python/branches/py3k/Modules/socketmodule.c	(original)
+++ python/branches/py3k/Modules/socketmodule.c	Mon May 26 15:28:38 2008
@@ -967,7 +967,7 @@
 #ifdef linux
 		if (a->sun_path[0] == 0) {  /* Linux abstract namespace */
 			addrlen -= offsetof(struct sockaddr_un, sun_path);
-			return PyString_FromStringAndSize(a->sun_path, addrlen);
+			return PyBytes_FromStringAndSize(a->sun_path, addrlen);
 		}
 		else
 #endif /* linux */
@@ -1326,12 +1326,12 @@
 
 			addr = (struct sockaddr_sco *)addr_ret;
 			_BT_SCO_MEMB(addr, family) = AF_BLUETOOTH;
-			if (!PyString_Check(args)) {
+			if (!PyBytes_Check(args)) {
 				PyErr_SetString(socket_error, "getsockaddrarg: "
 						"wrong format");
 				return 0;
 			}
-			straddr = PyString_AS_STRING(args);
+			straddr = PyBytes_AS_STRING(args);
 			if (setbdaddr(straddr, &_BT_SCO_MEMB(addr, bdaddr)) < 0)
 				return 0;
 
@@ -1773,16 +1773,16 @@
 				"getsockopt buflen out of range");
 		return NULL;
 	}
-	buf = PyString_FromStringAndSize((char *)NULL, buflen);
+	buf = PyBytes_FromStringAndSize((char *)NULL, buflen);
 	if (buf == NULL)
 		return NULL;
 	res = getsockopt(s->sock_fd, level, optname,
-			 (void *)PyString_AS_STRING(buf), &buflen);
+			 (void *)PyBytes_AS_STRING(buf), &buflen);
 	if (res < 0) {
 		Py_DECREF(buf);
 		return s->errorhandler();
 	}
-	_PyString_Resize(&buf, buflen);
+	_PyBytes_Resize(&buf, buflen);
 	return buf;
 }
 
@@ -2212,12 +2212,12 @@
 	}
 
 	/* Allocate a new string. */
-	buf = PyString_FromStringAndSize((char *) 0, recvlen);
+	buf = PyBytes_FromStringAndSize((char *) 0, recvlen);
 	if (buf == NULL)
 		return NULL;
 
 	/* Call the guts */
-	outlen = sock_recv_guts(s, PyString_AS_STRING(buf), recvlen, flags);
+	outlen = sock_recv_guts(s, PyBytes_AS_STRING(buf), recvlen, flags);
 	if (outlen < 0) {
 		/* An error occurred, release the string and return an
 		   error. */
@@ -2227,7 +2227,7 @@
 	if (outlen != recvlen) {
 		/* We did not read as many bytes as we anticipated, resize the
 		   string if possible and be successful. */
-		_PyString_Resize(&buf, outlen);
+		_PyBytes_Resize(&buf, outlen);
 	}
 
 	return buf;
@@ -2383,11 +2383,11 @@
 		return NULL;
 	}
 
-	buf = PyString_FromStringAndSize((char *) 0, recvlen);
+	buf = PyBytes_FromStringAndSize((char *) 0, recvlen);
 	if (buf == NULL)
 		return NULL;
 
-	outlen = sock_recvfrom_guts(s, PyString_AS_STRING(buf),
+	outlen = sock_recvfrom_guts(s, PyBytes_AS_STRING(buf),
 				    recvlen, flags, &addr);
 	if (outlen < 0) {
 		goto finally;
@@ -2396,7 +2396,7 @@
 	if (outlen != recvlen) {
 		/* We did not read as many bytes as we anticipated, resize the
 		   string if possible and be succesful. */
-		if (_PyString_Resize(&buf, outlen) < 0)
+		if (_PyBytes_Resize(&buf, outlen) < 0)
 			/* Oopsy, not so succesful after all. */
 			goto finally;
 	}
@@ -3519,7 +3519,7 @@
     if (inet_aton != NULL) {
 #endif
 	if (inet_aton(ip_addr, &buf))
-		return PyString_FromStringAndSize((char *)(&buf),
+		return PyBytes_FromStringAndSize((char *)(&buf),
 						  sizeof(buf));
 
 	PyErr_SetString(socket_error,
@@ -3548,7 +3548,7 @@
 			return NULL;
 		}
 	}
-	return PyString_FromStringAndSize((char *) &packed_addr,
+	return PyBytes_FromStringAndSize((char *) &packed_addr,
                                           sizeof(packed_addr));
 
 #ifdef USE_INET_ATON_WEAKLINK
@@ -3625,11 +3625,11 @@
 			"illegal IP address string passed to inet_pton");
 		return NULL;
 	} else if (af == AF_INET) {
-		return PyString_FromStringAndSize(packed,
+		return PyBytes_FromStringAndSize(packed,
                                                   sizeof(struct in_addr));
 #ifdef ENABLE_IPV6
 	} else if (af == AF_INET6) {
-		return PyString_FromStringAndSize(packed,
+		return PyBytes_FromStringAndSize(packed,
                                                   sizeof(struct in6_addr));
 #endif
 	} else {
@@ -3728,10 +3728,10 @@
 		idna = PyObject_CallMethod(hobj, "encode", "s", "idna");
 		if (!idna)
 			return NULL;
-		assert(PyString_Check(idna));
-		hptr = PyString_AS_STRING(idna);
-	} else if (PyString_Check(hobj)) {
-		hptr = PyString_AsString(hobj);
+		assert(PyBytes_Check(idna));
+		hptr = PyBytes_AS_STRING(idna);
+	} else if (PyBytes_Check(hobj)) {
+		hptr = PyBytes_AsString(hobj);
 	} else {
 		PyErr_SetString(PyExc_TypeError,
 				"getaddrinfo() argument 1 must be string or None");
@@ -3745,8 +3745,8 @@
 		pptr = pbuf;
 	} else if (PyUnicode_Check(pobj)) {
 		pptr = PyUnicode_AsString(pobj);
-	} else if (PyString_Check(pobj)) {
-		pptr = PyString_AsString(pobj);
+	} else if (PyBytes_Check(pobj)) {
+		pptr = PyBytes_AsString(pobj);
 	} else if (pobj == Py_None) {
 		pptr = (char *)NULL;
 	} else {

Modified: python/branches/py3k/Modules/termios.c
==============================================================================
--- python/branches/py3k/Modules/termios.c	(original)
+++ python/branches/py3k/Modules/termios.c	Mon May 26 15:28:38 2008
@@ -91,7 +91,7 @@
 		return NULL;
 	for (i = 0; i < NCCS; i++) {
 		ch = (char)mode.c_cc[i];
-		v = PyString_FromStringAndSize(&ch, 1);
+		v = PyBytes_FromStringAndSize(&ch, 1);
 		if (v == NULL)
 			goto err;
 		PyList_SetItem(cc, i, v);
@@ -183,8 +183,8 @@
 	for (i = 0; i < NCCS; i++) {
 		v = PyList_GetItem(cc, i);
 
-		if (PyString_Check(v) && PyString_Size(v) == 1)
-			mode.c_cc[i] = (cc_t) * PyString_AsString(v);
+		if (PyBytes_Check(v) && PyBytes_Size(v) == 1)
+			mode.c_cc[i] = (cc_t) * PyBytes_AsString(v);
 		else if (PyLong_Check(v))
 			mode.c_cc[i] = (cc_t) PyLong_AsLong(v);
 		else {

Modified: python/branches/py3k/Objects/abstract.c
==============================================================================
--- python/branches/py3k/Objects/abstract.c	(original)
+++ python/branches/py3k/Objects/abstract.c	Mon May 26 15:28:38 2008
@@ -1407,13 +1407,13 @@
 	}
 	PyErr_Clear();  /* It's not an error if  o.__trunc__ doesn't exist. */
 
-	if (PyString_Check(o))
+	if (PyBytes_Check(o))
 		/* need to do extra error checking that PyLong_FromString()
 		 * doesn't do.  In particular long('9.5') must raise an
 		 * exception, not truncate the float.
 		 */
-		return long_from_string(PyString_AS_STRING(o),
-					PyString_GET_SIZE(o));
+		return long_from_string(PyBytes_AS_STRING(o),
+					PyBytes_GET_SIZE(o));
 	if (PyUnicode_Check(o))
 		/* The above check is done in PyLong_FromUnicode(). */
 		return PyLong_FromUnicode(PyUnicode_AS_UNICODE(o),

Modified: python/branches/py3k/Objects/bytes_methods.c
==============================================================================
--- python/branches/py3k/Objects/bytes_methods.c	(original)
+++ python/branches/py3k/Objects/bytes_methods.c	Mon May 26 15:28:38 2008
@@ -462,11 +462,11 @@
 	Py_ssize_t i;
 
         /*
-	newobj = PyString_FromStringAndSize(NULL, len);
+	newobj = PyBytes_FromStringAndSize(NULL, len);
 	if (!newobj)
 		return NULL;
 
-	s = PyString_AS_STRING(newobj);
+	s = PyBytes_AS_STRING(newobj);
         */
 
 	Py_MEMCPY(result, cptr, len);
@@ -490,11 +490,11 @@
 	Py_ssize_t i;
 
         /*
-	newobj = PyString_FromStringAndSize(NULL, len);
+	newobj = PyBytes_FromStringAndSize(NULL, len);
 	if (!newobj)
 		return NULL;
 
-	s = PyString_AS_STRING(newobj);
+	s = PyBytes_AS_STRING(newobj);
         */
 
 	Py_MEMCPY(result, cptr, len);
@@ -520,10 +520,10 @@
 	int previous_is_cased = 0;
 
         /*
-	newobj = PyString_FromStringAndSize(NULL, len);
+	newobj = PyBytes_FromStringAndSize(NULL, len);
 	if (newobj == NULL)
 		return NULL;
-	s_new = PyString_AsString(newobj);
+	s_new = PyBytes_AsString(newobj);
         */
 	for (i = 0; i < len; i++) {
 		int c = Py_CHARMASK(*s++);
@@ -553,10 +553,10 @@
 	Py_ssize_t i;
 
         /*
-	newobj = PyString_FromStringAndSize(NULL, len);
+	newobj = PyBytes_FromStringAndSize(NULL, len);
 	if (newobj == NULL)
 		return NULL;
-	s_new = PyString_AsString(newobj);
+	s_new = PyBytes_AsString(newobj);
         */
 	if (0 < len) {
 		int c = Py_CHARMASK(*s++);
@@ -589,10 +589,10 @@
 	Py_ssize_t i;
 
         /*
-	newobj = PyString_FromStringAndSize(NULL, len);
+	newobj = PyBytes_FromStringAndSize(NULL, len);
 	if (newobj == NULL)
 		return NULL;
-	s_new = PyString_AsString(newobj);
+	s_new = PyBytes_AsString(newobj);
         */
 	for (i = 0; i < len; i++) {
 		int c = Py_CHARMASK(*s++);

Modified: python/branches/py3k/Objects/bytesobject.c
==============================================================================
--- python/branches/py3k/Objects/bytesobject.c	(original)
+++ python/branches/py3k/Objects/bytesobject.c	Mon May 26 15:28:38 2008
@@ -728,7 +728,7 @@
         encoded = PyCodec_Encode(arg, encoding, errors);
         if (encoded == NULL)
             return -1;
-        assert(PyString_Check(encoded));
+        assert(PyBytes_Check(encoded));
         new = bytes_iconcat(self, encoded);
         Py_DECREF(encoded);
         if (new == NULL)
@@ -2895,7 +2895,7 @@
     /* XXX Shouldn't we use _getbuffer() on these items instead? */
     for (i = 0; i < n; i++) {
         PyObject *obj = items[i];
-        if (!PyByteArray_Check(obj) && !PyString_Check(obj)) {
+        if (!PyByteArray_Check(obj) && !PyBytes_Check(obj)) {
             PyErr_Format(PyExc_TypeError,
                          "can only join an iterable of bytes "
                          "(item %ld has type '%.100s')",
@@ -2924,7 +2924,7 @@
         if (PyByteArray_Check(obj))
            buf = PyByteArray_AS_STRING(obj);
         else
-           buf = PyString_AS_STRING(obj);
+           buf = PyBytes_AS_STRING(obj);
         if (i) {
             memcpy(dest, self->ob_bytes, mysize);
             dest += mysize;

Modified: python/branches/py3k/Objects/codeobject.c
==============================================================================
--- python/branches/py3k/Objects/codeobject.c	(original)
+++ python/branches/py3k/Objects/codeobject.c	Mon May 26 15:28:38 2008
@@ -63,7 +63,7 @@
 	    cellvars == NULL || !PyTuple_Check(cellvars) ||
 	    name == NULL || !PyUnicode_Check(name) ||
 	    filename == NULL || !PyUnicode_Check(filename) ||
-	    lnotab == NULL || !PyString_Check(lnotab) ||
+	    lnotab == NULL || !PyBytes_Check(lnotab) ||
 	    !PyObject_CheckReadBuffer(code)) {
 		PyErr_BadInternalCall();
 		return NULL;
@@ -478,8 +478,8 @@
 int
 PyCode_Addr2Line(PyCodeObject *co, int addrq)
 {
-	int size = PyString_Size(co->co_lnotab) / 2;
-	unsigned char *p = (unsigned char*)PyString_AsString(co->co_lnotab);
+	int size = PyBytes_Size(co->co_lnotab) / 2;
+	unsigned char *p = (unsigned char*)PyBytes_AsString(co->co_lnotab);
 	int line = co->co_firstlineno;
 	int addr = 0;
 	while (--size >= 0) {
@@ -574,8 +574,8 @@
         int size, addr, line;
         unsigned char* p;
 
-        p = (unsigned char*)PyString_AS_STRING(co->co_lnotab);
-        size = PyString_GET_SIZE(co->co_lnotab) / 2;
+        p = (unsigned char*)PyBytes_AS_STRING(co->co_lnotab);
+        size = PyBytes_GET_SIZE(co->co_lnotab) / 2;
 
         addr = 0;
         line = co->co_firstlineno;

Modified: python/branches/py3k/Objects/exceptions.c
==============================================================================
--- python/branches/py3k/Objects/exceptions.c	(original)
+++ python/branches/py3k/Objects/exceptions.c	Mon May 26 15:28:38 2008
@@ -1061,7 +1061,7 @@
         return NULL;
     }
 
-    if (!PyString_Check(attr)) {
+    if (!PyBytes_Check(attr)) {
         PyErr_Format(PyExc_TypeError, "%.200s attribute must be bytes", name);
         return NULL;
     }
@@ -1153,7 +1153,7 @@
     PyObject *obj = get_string(((PyUnicodeErrorObject *)exc)->object, "object");
     if (!obj)
         return -1;
-    size = PyString_GET_SIZE(obj);
+    size = PyBytes_GET_SIZE(obj);
     *start = ((PyUnicodeErrorObject *)exc)->start;
     if (*start<0)
         *start = 0;
@@ -1221,7 +1221,7 @@
     PyObject *obj = get_string(((PyUnicodeErrorObject *)exc)->object, "object");
     if (!obj)
         return -1;
-    size = PyString_GET_SIZE(obj);
+    size = PyBytes_GET_SIZE(obj);
     *end = ((PyUnicodeErrorObject *)exc)->end;
     if (*end<1)
         *end = 1;
@@ -1468,12 +1468,12 @@
              return -1;
     }
 
-    if (!PyString_Check(ude->object)) {
+    if (!PyBytes_Check(ude->object)) {
         if (PyObject_AsReadBuffer(ude->object, (const void **)&data, &size)) {
             ude->encoding = ude->object = ude->reason = NULL;
             return -1;
         }
-        ude->object = PyString_FromStringAndSize(data, size);
+        ude->object = PyBytes_FromStringAndSize(data, size);
     }
     else {
         Py_INCREF(ude->object);
@@ -1491,7 +1491,7 @@
     PyUnicodeErrorObject *uself = (PyUnicodeErrorObject *)self;
 
     if (uself->end==uself->start+1) {
-        int byte = (int)(PyString_AS_STRING(((PyUnicodeErrorObject *)self)->object)[uself->start]&0xff);
+        int byte = (int)(PyBytes_AS_STRING(((PyUnicodeErrorObject *)self)->object)[uself->start]&0xff);
         return PyUnicode_FromFormat(
             "'%U' codec can't decode byte 0x%02x in position %zd: %U",
             ((PyUnicodeErrorObject *)self)->encoding,

Modified: python/branches/py3k/Objects/fileobject.c
==============================================================================
--- python/branches/py3k/Objects/fileobject.c	(original)
+++ python/branches/py3k/Objects/fileobject.c	Mon May 26 15:28:38 2008
@@ -81,7 +81,7 @@
 		result = PyEval_CallObject(reader, args);
 		Py_DECREF(reader);
 		Py_DECREF(args);
-		if (result != NULL && !PyString_Check(result) &&
+		if (result != NULL && !PyBytes_Check(result) &&
 		    !PyUnicode_Check(result)) {
 			Py_DECREF(result);
 			result = NULL;
@@ -90,9 +90,9 @@
 		}
 	}
 
-	if (n < 0 && result != NULL && PyString_Check(result)) {
-		char *s = PyString_AS_STRING(result);
-		Py_ssize_t len = PyString_GET_SIZE(result);
+	if (n < 0 && result != NULL && PyBytes_Check(result)) {
+		char *s = PyBytes_AS_STRING(result);
+		Py_ssize_t len = PyBytes_GET_SIZE(result);
 		if (len == 0) {
 			Py_DECREF(result);
 			result = NULL;
@@ -101,10 +101,10 @@
 		}
 		else if (s[len-1] == '\n') {
 			if (result->ob_refcnt == 1)
-				_PyString_Resize(&result, len-1);
+				_PyBytes_Resize(&result, len-1);
 			else {
 				PyObject *v;
-				v = PyString_FromStringAndSize(s, len-1);
+				v = PyBytes_FromStringAndSize(s, len-1);
 				Py_DECREF(result);
 				result = v;
 			}

Modified: python/branches/py3k/Objects/frameobject.c
==============================================================================
--- python/branches/py3k/Objects/frameobject.c	(original)
+++ python/branches/py3k/Objects/frameobject.c	Mon May 26 15:28:38 2008
@@ -128,7 +128,7 @@
 
 	/* Find the bytecode offset for the start of the given line, or the
 	 * first code-owning line after it. */
-	PyString_AsStringAndSize(f->f_code->co_lnotab, &lnotab, &lnotab_len);
+	PyBytes_AsStringAndSize(f->f_code->co_lnotab, &lnotab, &lnotab_len);
 	addr = 0;
 	line = f->f_code->co_firstlineno;
 	new_lasti = -1;
@@ -151,7 +151,7 @@
 	}
 
 	/* We're now ready to look at the bytecode. */
-	PyString_AsStringAndSize(f->f_code->co_code, (char **)&code, &code_len);
+	PyBytes_AsStringAndSize(f->f_code->co_code, (char **)&code, &code_len);
 	min_addr = MIN(new_lasti, f->f_lasti);
 	max_addr = MAX(new_lasti, f->f_lasti);
 

Modified: python/branches/py3k/Objects/longobject.c
==============================================================================
--- python/branches/py3k/Objects/longobject.c	(original)
+++ python/branches/py3k/Objects/longobject.c	Mon May 26 15:28:38 2008
@@ -3518,7 +3518,7 @@
 		return PyLong_FromUnicode(PyUnicode_AS_UNICODE(x),
 					  PyUnicode_GET_SIZE(x),
 					  base);
-	else if (PyByteArray_Check(x) || PyString_Check(x)) {
+	else if (PyByteArray_Check(x) || PyBytes_Check(x)) {
 		/* Since PyLong_FromString doesn't have a length parameter,
 		 * check here for possible NULs in the string. */
 		char *string;
@@ -3526,7 +3526,7 @@
 		if (PyByteArray_Check(x))
 			string = PyByteArray_AS_STRING(x);
 		else
-			string = PyString_AS_STRING(x);
+			string = PyBytes_AS_STRING(x);
 		if (strlen(string) != size) {
 			/* We only see this if there's a null byte in x,
 			   x is a bytes or buffer, *and* a base is given. */

Modified: python/branches/py3k/Objects/object.c
==============================================================================
--- python/branches/py3k/Objects/object.c	(original)
+++ python/branches/py3k/Objects/object.c	Mon May 26 15:28:38 2008
@@ -291,9 +291,9 @@
 				s = PyObject_Repr(op);
 			if (s == NULL)
 				ret = -1;
-                        else if (PyString_Check(s)) {
-				fwrite(PyString_AS_STRING(s), 1,
-				       PyString_GET_SIZE(s), fp);
+                        else if (PyBytes_Check(s)) {
+				fwrite(PyBytes_AS_STRING(s), 1,
+				       PyBytes_GET_SIZE(s), fp);
 			}
 			else if (PyUnicode_Check(s)) {
 				PyObject *t;
@@ -301,8 +301,8 @@
 				if (t == NULL)
 					ret = 0;
 				else {
-					fwrite(PyString_AS_STRING(t), 1,
-					       PyString_GET_SIZE(t), fp);
+					fwrite(PyBytes_AS_STRING(t), 1,
+					       PyBytes_GET_SIZE(t), fp);
 				}
 			}
 			else {
@@ -1498,7 +1498,7 @@
 	if (PyType_Ready(&PyByteArray_Type) < 0)
 		Py_FatalError("Can't initialize 'bytes'");
 
-	if (PyType_Ready(&PyString_Type) < 0)
+	if (PyType_Ready(&PyBytes_Type) < 0)
 		Py_FatalError("Can't initialize 'str'");
 
 	if (PyType_Ready(&PyList_Type) < 0)

Modified: python/branches/py3k/Objects/stringlib/formatter.h
==============================================================================
--- python/branches/py3k/Objects/stringlib/formatter.h	(original)
+++ python/branches/py3k/Objects/stringlib/formatter.h	Mon May 26 15:28:38 2008
@@ -778,7 +778,7 @@
     /* This is to allow things like u''.format('') */
     if (!PyArg_ParseTuple(args, "O:__format__", &format_spec))
         goto done;
-    if (!(PyString_Check(format_spec) || PyUnicode_Check(format_spec))) {
+    if (!(PyBytes_Check(format_spec) || PyUnicode_Check(format_spec))) {
         PyErr_Format(PyExc_TypeError, "__format__ arg must be str "
 		     "or unicode, not %s", Py_TYPE(format_spec)->tp_name);
 	goto done;

Modified: python/branches/py3k/Objects/stringlib/string_format.h
==============================================================================
--- python/branches/py3k/Objects/stringlib/string_format.h	(original)
+++ python/branches/py3k/Objects/stringlib/string_format.h	Mon May 26 15:28:38 2008
@@ -496,7 +496,7 @@
 #if PY_VERSION_HEX >= 0x03000000
     assert(PyUnicode_Check(result));
 #else
-    assert(PyString_Check(result) || PyUnicode_Check(result));
+    assert(PyBytes_Check(result) || PyUnicode_Check(result));
 
     /* Convert result to our type.  We could be str, and result could
        be unicode */

Modified: python/branches/py3k/Objects/stringlib/stringdefs.h
==============================================================================
--- python/branches/py3k/Objects/stringlib/stringdefs.h	(original)
+++ python/branches/py3k/Objects/stringlib/stringdefs.h	Mon May 26 15:28:38 2008
@@ -6,7 +6,7 @@
    compiled as unicode. */
 #define STRINGLIB_IS_UNICODE     0
 
-#define STRINGLIB_OBJECT         PyStringObject
+#define STRINGLIB_OBJECT         PyBytesObject
 #define STRINGLIB_CHAR           char
 #define STRINGLIB_TYPE_NAME      "string"
 #define STRINGLIB_PARSE_CODE     "S"
@@ -16,13 +16,13 @@
 #define STRINGLIB_TOUPPER        toupper
 #define STRINGLIB_TOLOWER        tolower
 #define STRINGLIB_FILL           memset
-#define STRINGLIB_STR            PyString_AS_STRING
-#define STRINGLIB_LEN            PyString_GET_SIZE
-#define STRINGLIB_NEW            PyString_FromStringAndSize
-#define STRINGLIB_RESIZE         _PyString_Resize
-#define STRINGLIB_CHECK          PyString_Check
+#define STRINGLIB_STR            PyBytes_AS_STRING
+#define STRINGLIB_LEN            PyBytes_GET_SIZE
+#define STRINGLIB_NEW            PyBytes_FromStringAndSize
+#define STRINGLIB_RESIZE         _PyBytes_Resize
+#define STRINGLIB_CHECK          PyBytes_Check
 #define STRINGLIB_CMP            memcmp
 #define STRINGLIB_TOSTR          PyObject_Str
-#define STRINGLIB_GROUPING       _PyString_InsertThousandsGrouping
+#define STRINGLIB_GROUPING       _PyBytes_InsertThousandsGrouping
 
 #endif /* !STRINGLIB_STRINGDEFS_H */

Modified: python/branches/py3k/Objects/stringobject.c
==============================================================================
--- python/branches/py3k/Objects/stringobject.c	(original)
+++ python/branches/py3k/Objects/stringobject.c	Mon May 26 15:28:38 2008
@@ -31,23 +31,23 @@
 int null_strings, one_strings;
 #endif
 
-static PyStringObject *characters[UCHAR_MAX + 1];
-static PyStringObject *nullstring;
+static PyBytesObject *characters[UCHAR_MAX + 1];
+static PyBytesObject *nullstring;
 
 /*
-   For both PyString_FromString() and PyString_FromStringAndSize(), the
+   For both PyBytes_FromString() and PyBytes_FromStringAndSize(), the
    parameter `size' denotes number of characters to allocate, not counting any
    null terminating character.
 
-   For PyString_FromString(), the parameter `str' points to a null-terminated
+   For PyBytes_FromString(), the parameter `str' points to a null-terminated
    string containing exactly `size' bytes.
 
-   For PyString_FromStringAndSize(), the parameter the parameter `str' is
+   For PyBytes_FromStringAndSize(), the parameter the parameter `str' is
    either NULL or else points to a string containing at least `size' bytes.
-   For PyString_FromStringAndSize(), the string in the `str' parameter does
+   For PyBytes_FromStringAndSize(), the string in the `str' parameter does
    not have to be null-terminated.  (Therefore it is safe to construct a
-   substring by calling `PyString_FromStringAndSize(origstring, substrlen)'.)
-   If `str' is NULL then PyString_FromStringAndSize() will allocate `size+1'
+   substring by calling `PyBytes_FromStringAndSize(origstring, substrlen)'.)
+   If `str' is NULL then PyBytes_FromStringAndSize() will allocate `size+1'
    bytes (setting the last byte to the null terminating character) and you can
    fill in the data yourself.  If `str' is non-NULL then the resulting
    PyString object must be treated as immutable and you must not fill in nor
@@ -57,16 +57,16 @@
    items" in a variable-size object, will contain the number of bytes
    allocated for string data, not counting the null terminating character.  It
    is therefore equal to the equal to the `size' parameter (for
-   PyString_FromStringAndSize()) or the length of the string in the `str'
-   parameter (for PyString_FromString()).
+   PyBytes_FromStringAndSize()) or the length of the string in the `str'
+   parameter (for PyBytes_FromString()).
 */
 PyObject *
-PyString_FromStringAndSize(const char *str, Py_ssize_t size)
+PyBytes_FromStringAndSize(const char *str, Py_ssize_t size)
 {
-	register PyStringObject *op;
+	register PyBytesObject *op;
 	if (size < 0) {
 		PyErr_SetString(PyExc_SystemError,
-		    "Negative size passed to PyString_FromStringAndSize");
+		    "Negative size passed to PyBytes_FromStringAndSize");
 		return NULL;
 	}
 	if (size == 0 && (op = nullstring) != NULL) {
@@ -87,10 +87,10 @@
 	}
 
 	/* Inline PyObject_NewVar */
-	op = (PyStringObject *)PyObject_MALLOC(sizeof(PyStringObject) + size);
+	op = (PyBytesObject *)PyObject_MALLOC(sizeof(PyBytesObject) + size);
 	if (op == NULL)
 		return PyErr_NoMemory();
-	PyObject_INIT_VAR(op, &PyString_Type, size);
+	PyObject_INIT_VAR(op, &PyBytes_Type, size);
 	op->ob_shash = -1;
 	if (str != NULL)
 		Py_MEMCPY(op->ob_sval, str, size);
@@ -107,10 +107,10 @@
 }
 
 PyObject *
-PyString_FromString(const char *str)
+PyBytes_FromString(const char *str)
 {
 	register size_t size;
-	register PyStringObject *op;
+	register PyBytesObject *op;
 
 	assert(str != NULL);
 	size = strlen(str);
@@ -135,10 +135,10 @@
 	}
 
 	/* Inline PyObject_NewVar */
-	op = (PyStringObject *)PyObject_MALLOC(sizeof(PyStringObject) + size);
+	op = (PyBytesObject *)PyObject_MALLOC(sizeof(PyBytesObject) + size);
 	if (op == NULL)
 		return PyErr_NoMemory();
-	PyObject_INIT_VAR(op, &PyString_Type, size);
+	PyObject_INIT_VAR(op, &PyBytes_Type, size);
 	op->ob_shash = -1;
 	Py_MEMCPY(op->ob_sval, str, size+1);
 	/* share short strings */
@@ -153,7 +153,7 @@
 }
 
 PyObject *
-PyString_FromFormatV(const char *format, va_list vargs)
+PyBytes_FromFormatV(const char *format, va_list vargs)
 {
 	va_list count;
 	Py_ssize_t n = 0;
@@ -228,11 +228,11 @@
 	/* step 2: fill the buffer */
 	/* Since we've analyzed how much space we need for the worst case,
 	   use sprintf directly instead of the slower PyOS_snprintf. */
-	string = PyString_FromStringAndSize(NULL, n);
+	string = PyBytes_FromStringAndSize(NULL, n);
 	if (!string)
 		return NULL;
 
-	s = PyString_AsString(string);
+	s = PyBytes_AsString(string);
 
 	for (f = format; *f; f++) {
 		if (*f == '%') {
@@ -332,12 +332,12 @@
 	}
 
  end:
-	_PyString_Resize(&string, s - PyString_AS_STRING(string));
+	_PyBytes_Resize(&string, s - PyBytes_AS_STRING(string));
 	return string;
 }
 
 PyObject *
-PyString_FromFormat(const char *format, ...)
+PyBytes_FromFormat(const char *format, ...)
 {
 	PyObject* ret;
 	va_list vargs;
@@ -347,7 +347,7 @@
 #else
 	va_start(vargs);
 #endif
-	ret = PyString_FromFormatV(format, vargs);
+	ret = PyBytes_FromFormatV(format, vargs);
 	va_end(vargs);
 	return ret;
 }
@@ -363,7 +363,7 @@
    the string is UTF-8 encoded and should be re-encoded in the
    specified encoding.  */
 
-PyObject *PyString_DecodeEscape(const char *s,
+PyObject *PyBytes_DecodeEscape(const char *s,
 				Py_ssize_t len,
 				const char *errors,
 				Py_ssize_t unicode,
@@ -374,10 +374,10 @@
 	const char *end;
 	PyObject *v;
 	Py_ssize_t newlen = recode_encoding ? 4*len:len;
-	v = PyString_FromStringAndSize((char *)NULL, newlen);
+	v = PyBytes_FromStringAndSize((char *)NULL, newlen);
 	if (v == NULL)
 		return NULL;
-	p = buf = PyString_AsString(v);
+	p = buf = PyBytes_AsString(v);
 	end = s + len;
 	while (s < end) {
 		if (*s != '\\') {
@@ -400,9 +400,9 @@
 				if (!w)	goto failed;
 
 				/* Append bytes to output buffer. */
-				assert(PyString_Check(w));
-				r = PyString_AS_STRING(w);
-				rn = PyString_GET_SIZE(w);
+				assert(PyBytes_Check(w));
+				r = PyBytes_AS_STRING(w);
+				rn = PyBytes_GET_SIZE(w);
 				Py_MEMCPY(p, r, rn);
 				p += rn;
 				Py_DECREF(w);
@@ -488,7 +488,7 @@
 		}
 	}
 	if (p-buf < newlen)
-		_PyString_Resize(&v, p - buf);
+		_PyBytes_Resize(&v, p - buf);
 	return v;
   failed:
 	Py_DECREF(v);
@@ -499,9 +499,9 @@
 /* object api */
 
 Py_ssize_t
-PyString_Size(register PyObject *op)
+PyBytes_Size(register PyObject *op)
 {
-	if (!PyString_Check(op)) {
+	if (!PyBytes_Check(op)) {
 		PyErr_Format(PyExc_TypeError,
 		     "expected bytes, %.200s found", Py_TYPE(op)->tp_name);
 		return -1;
@@ -510,18 +510,18 @@
 }
 
 char *
-PyString_AsString(register PyObject *op)
+PyBytes_AsString(register PyObject *op)
 {
-	if (!PyString_Check(op)) {
+	if (!PyBytes_Check(op)) {
 		PyErr_Format(PyExc_TypeError,
 		     "expected bytes, %.200s found", Py_TYPE(op)->tp_name);
 		return NULL;
 	}
-	return ((PyStringObject *)op)->ob_sval;
+	return ((PyBytesObject *)op)->ob_sval;
 }
 
 int
-PyString_AsStringAndSize(register PyObject *obj,
+PyBytes_AsStringAndSize(register PyObject *obj,
 			 register char **s,
 			 register Py_ssize_t *len)
 {
@@ -530,16 +530,16 @@
 		return -1;
 	}
 
-	if (!PyString_Check(obj)) {
+	if (!PyBytes_Check(obj)) {
 		PyErr_Format(PyExc_TypeError,
 		     "expected bytes, %.200s found", Py_TYPE(obj)->tp_name);
 		return -1;
 	}
 
-	*s = PyString_AS_STRING(obj);
+	*s = PyBytes_AS_STRING(obj);
 	if (len != NULL)
-		*len = PyString_GET_SIZE(obj);
-	else if (strlen(*s) != (size_t)PyString_GET_SIZE(obj)) {
+		*len = PyBytes_GET_SIZE(obj);
+	else if (strlen(*s) != (size_t)PyBytes_GET_SIZE(obj)) {
 		PyErr_SetString(PyExc_TypeError,
 				"expected bytes with no null");
 		return -1;
@@ -553,13 +553,13 @@
 #define STRINGLIB_CHAR char
 
 #define STRINGLIB_CMP memcmp
-#define STRINGLIB_LEN PyString_GET_SIZE
-#define STRINGLIB_NEW PyString_FromStringAndSize
-#define STRINGLIB_STR PyString_AS_STRING
+#define STRINGLIB_LEN PyBytes_GET_SIZE
+#define STRINGLIB_NEW PyBytes_FromStringAndSize
+#define STRINGLIB_STR PyBytes_AS_STRING
 /* #define STRINGLIB_WANT_CONTAINS_OBJ 1 */
 
 #define STRINGLIB_EMPTY nullstring
-#define STRINGLIB_CHECK_EXACT PyString_CheckExact
+#define STRINGLIB_CHECK_EXACT PyBytes_CheckExact
 #define STRINGLIB_MUTABLE 0
 
 #include "stringlib/fastsearch.h"
@@ -570,14 +570,14 @@
 #include "stringlib/ctype.h"
 #include "stringlib/transmogrify.h"
 
-#define _Py_InsertThousandsGrouping _PyString_InsertThousandsGrouping
+#define _Py_InsertThousandsGrouping _PyBytes_InsertThousandsGrouping
 #include "stringlib/localeutil.h"
 
 PyObject *
-PyString_Repr(PyObject *obj, int smartquotes)
+PyBytes_Repr(PyObject *obj, int smartquotes)
 {
 	static const char *hexdigits = "0123456789abcdef";
-	register PyStringObject* op = (PyStringObject*) obj;
+	register PyBytesObject* op = (PyBytesObject*) obj;
 	Py_ssize_t length = Py_SIZE(op);
 	size_t newsize = 3 + 4 * length;
 	PyObject *v;
@@ -600,7 +600,7 @@
 		quote = '\'';
 		if (smartquotes) {
 			char *test, *start;
-			start = PyString_AS_STRING(op);
+			start = PyBytes_AS_STRING(op);
 			for (test = start; test < start+length; ++test) {
 				if (*test == '"') {
 					quote = '\''; /* back to single */
@@ -650,7 +650,7 @@
 static PyObject *
 string_repr(PyObject *op)
 {
-	return PyString_Repr(op, 1);
+	return PyBytes_Repr(op, 1);
 }
 
 static PyObject *
@@ -665,12 +665,12 @@
 }
 
 static Py_ssize_t
-string_length(PyStringObject *a)
+string_length(PyBytesObject *a)
 {
 	return Py_SIZE(a);
 }
 
-/* This is also used by PyString_Concat() */
+/* This is also used by PyBytes_Concat() */
 static PyObject *
 string_concat(PyObject *a, PyObject *b)
 {
@@ -688,12 +688,12 @@
 	}
 
 	/* Optimize end cases */
-	if (va.len == 0 && PyString_CheckExact(b)) {
+	if (va.len == 0 && PyBytes_CheckExact(b)) {
 		result = b;
 		Py_INCREF(result);
 		goto done;
 	}
-	if (vb.len == 0 && PyString_CheckExact(a)) {
+	if (vb.len == 0 && PyBytes_CheckExact(a)) {
 		result = a;
 		Py_INCREF(result);
 		goto done;
@@ -705,10 +705,10 @@
 		goto done;
 	}
 
-	result = PyString_FromStringAndSize(NULL, size);
+	result = PyBytes_FromStringAndSize(NULL, size);
 	if (result != NULL) {
-		memcpy(PyString_AS_STRING(result), va.buf, va.len);
-		memcpy(PyString_AS_STRING(result) + va.len, vb.buf, vb.len);
+		memcpy(PyBytes_AS_STRING(result), va.buf, va.len);
+		memcpy(PyBytes_AS_STRING(result) + va.len, vb.buf, vb.len);
 	}
 
   done:
@@ -720,12 +720,12 @@
 }
 
 static PyObject *
-string_repeat(register PyStringObject *a, register Py_ssize_t n)
+string_repeat(register PyBytesObject *a, register Py_ssize_t n)
 {
 	register Py_ssize_t i;
 	register Py_ssize_t j;
 	register Py_ssize_t size;
-	register PyStringObject *op;
+	register PyBytesObject *op;
 	size_t nbytes;
 	if (n < 0)
 		n = 0;
@@ -738,21 +738,21 @@
 			"repeated string is too long");
 		return NULL;
 	}
-	if (size == Py_SIZE(a) && PyString_CheckExact(a)) {
+	if (size == Py_SIZE(a) && PyBytes_CheckExact(a)) {
 		Py_INCREF(a);
 		return (PyObject *)a;
 	}
 	nbytes = (size_t)size;
-	if (nbytes + sizeof(PyStringObject) <= nbytes) {
+	if (nbytes + sizeof(PyBytesObject) <= nbytes) {
 		PyErr_SetString(PyExc_OverflowError,
 			"repeated string is too long");
 		return NULL;
 	}
-	op = (PyStringObject *)
-		PyObject_MALLOC(sizeof(PyStringObject) + nbytes);
+	op = (PyBytesObject *)
+		PyObject_MALLOC(sizeof(PyBytesObject) + nbytes);
 	if (op == NULL)
 		return PyErr_NoMemory();
-	PyObject_INIT_VAR(op, &PyString_Type, size);
+	PyObject_INIT_VAR(op, &PyBytes_Type, size);
 	op->ob_shash = -1;
 	op->ob_sval[size] = '\0';
 	if (Py_SIZE(a) == 1 && n > 0) {
@@ -782,7 +782,7 @@
         PyErr_Clear();
         if (_getbuffer(arg, &varg) < 0)
             return -1;
-        pos = stringlib_find(PyString_AS_STRING(self), Py_SIZE(self),
+        pos = stringlib_find(PyBytes_AS_STRING(self), Py_SIZE(self),
                              varg.buf, varg.len, 0);
         PyObject_ReleaseBuffer(arg, &varg);
         return pos >= 0;
@@ -792,11 +792,11 @@
         return -1;
     }
 
-    return memchr(PyString_AS_STRING(self), ival, Py_SIZE(self)) != NULL;
+    return memchr(PyBytes_AS_STRING(self), ival, Py_SIZE(self)) != NULL;
 }
 
 static PyObject *
-string_item(PyStringObject *a, register Py_ssize_t i)
+string_item(PyBytesObject *a, register Py_ssize_t i)
 {
 	if (i < 0 || i >= Py_SIZE(a)) {
 		PyErr_SetString(PyExc_IndexError, "string index out of range");
@@ -806,7 +806,7 @@
 }
 
 static PyObject*
-string_richcompare(PyStringObject *a, PyStringObject *b, int op)
+string_richcompare(PyBytesObject *a, PyBytesObject *b, int op)
 {
 	int c;
 	Py_ssize_t len_a, len_b;
@@ -814,7 +814,7 @@
 	PyObject *result;
 
 	/* Make sure both arguments are strings. */
-	if (!(PyString_Check(a) && PyString_Check(b))) {
+	if (!(PyBytes_Check(a) && PyBytes_Check(b))) {
 		if (Py_BytesWarningFlag && (op == Py_EQ) &&
 		    (PyObject_IsInstance((PyObject*)a,
 					 (PyObject*)&PyUnicode_Type) ||
@@ -877,7 +877,7 @@
 }
 
 static long
-string_hash(PyStringObject *a)
+string_hash(PyBytesObject *a)
 {
 	register Py_ssize_t len;
 	register unsigned char *p;
@@ -898,15 +898,15 @@
 }
 
 static PyObject*
-string_subscript(PyStringObject* self, PyObject* item)
+string_subscript(PyBytesObject* self, PyObject* item)
 {
 	if (PyIndex_Check(item)) {
 		Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError);
 		if (i == -1 && PyErr_Occurred())
 			return NULL;
 		if (i < 0)
-			i += PyString_GET_SIZE(self);
-		if (i < 0 || i >= PyString_GET_SIZE(self)) {
+			i += PyBytes_GET_SIZE(self);
+		if (i < 0 || i >= PyBytes_GET_SIZE(self)) {
 			PyErr_SetString(PyExc_IndexError,
 					"string index out of range");
 			return NULL;
@@ -920,27 +920,27 @@
 		PyObject* result;
 
 		if (PySlice_GetIndicesEx((PySliceObject*)item,
-				 PyString_GET_SIZE(self),
+				 PyBytes_GET_SIZE(self),
 				 &start, &stop, &step, &slicelength) < 0) {
 			return NULL;
 		}
 
 		if (slicelength <= 0) {
-			return PyString_FromStringAndSize("", 0);
+			return PyBytes_FromStringAndSize("", 0);
 		}
 		else if (start == 0 && step == 1 &&
-			 slicelength == PyString_GET_SIZE(self) &&
-			 PyString_CheckExact(self)) {
+			 slicelength == PyBytes_GET_SIZE(self) &&
+			 PyBytes_CheckExact(self)) {
 			Py_INCREF(self);
 			return (PyObject *)self;
 		}
 		else if (step == 1) {
-			return PyString_FromStringAndSize(
-				PyString_AS_STRING(self) + start,
+			return PyBytes_FromStringAndSize(
+				PyBytes_AS_STRING(self) + start,
 				slicelength);
 		}
 		else {
-			source_buf = PyString_AsString((PyObject*)self);
+			source_buf = PyBytes_AsString((PyObject*)self);
 			result_buf = (char *)PyMem_Malloc(slicelength);
 			if (result_buf == NULL)
 				return PyErr_NoMemory();
@@ -950,7 +950,7 @@
 				result_buf[i] = source_buf[cur];
 			}
 
-			result = PyString_FromStringAndSize(result_buf,
+			result = PyBytes_FromStringAndSize(result_buf,
 							    slicelength);
 			PyMem_Free(result_buf);
 			return result;
@@ -965,7 +965,7 @@
 }
 
 static int
-string_buffer_getbuffer(PyStringObject *self, Py_buffer *view, int flags)
+string_buffer_getbuffer(PyBytesObject *self, Py_buffer *view, int flags)
 {
 	return PyBuffer_FillInfo(view, (void *)self->ob_sval, Py_SIZE(self),
 				 0, flags);
@@ -1025,7 +1025,7 @@
 	(maxsplit >= MAX_PREALLOC ? MAX_PREALLOC : maxsplit+1)
 
 #define SPLIT_ADD(data, left, right) {				\
-	str = PyString_FromStringAndSize((data) + (left),	\
+	str = PyBytes_FromStringAndSize((data) + (left),	\
 					 (right) - (left));	\
 	if (str == NULL)					\
 		goto onError;					\
@@ -1050,9 +1050,9 @@
 #define RSKIP_NONSPACE(s, i)     { while (i>=0  && !ISSPACE(s[i])) i--; }
 
 Py_LOCAL_INLINE(PyObject *)
-split_whitespace(PyStringObject *self, Py_ssize_t len, Py_ssize_t maxsplit)
+split_whitespace(PyBytesObject *self, Py_ssize_t len, Py_ssize_t maxsplit)
 {
-	const char *s = PyString_AS_STRING(self);
+	const char *s = PyBytes_AS_STRING(self);
 	Py_ssize_t i, j, count=0;
 	PyObject *str;
 	PyObject *list = PyList_New(PREALLOC_SIZE(maxsplit));
@@ -1067,7 +1067,7 @@
 		if (i==len) break;
 		j = i; i++;
 		SKIP_NONSPACE(s, i, len);
-		if (j == 0 && i == len && PyString_CheckExact(self)) {
+		if (j == 0 && i == len && PyBytes_CheckExact(self)) {
 			/* No whitespace in self, so just use it as list[0] */
 			Py_INCREF(self);
 			PyList_SET_ITEM(list, 0, (PyObject *)self);
@@ -1092,9 +1092,9 @@
 }
 
 Py_LOCAL_INLINE(PyObject *)
-split_char(PyStringObject *self, Py_ssize_t len, char ch, Py_ssize_t maxcount)
+split_char(PyBytesObject *self, Py_ssize_t len, char ch, Py_ssize_t maxcount)
 {
-	const char *s = PyString_AS_STRING(self);
+	const char *s = PyBytes_AS_STRING(self);
 	register Py_ssize_t i, j, count=0;
 	PyObject *str;
 	PyObject *list = PyList_New(PREALLOC_SIZE(maxcount));
@@ -1113,7 +1113,7 @@
 			}
 		}
 	}
-	if (i == 0 && count == 0 && PyString_CheckExact(self)) {
+	if (i == 0 && count == 0 && PyBytes_CheckExact(self)) {
 		/* ch not in self, so just use self as list[0] */
 		Py_INCREF(self);
 		PyList_SET_ITEM(list, 0, (PyObject *)self);
@@ -1139,11 +1139,11 @@
 If maxsplit is given, at most maxsplit splits are done.");
 
 static PyObject *
-string_split(PyStringObject *self, PyObject *args)
+string_split(PyBytesObject *self, PyObject *args)
 {
-	Py_ssize_t len = PyString_GET_SIZE(self), n, i, j;
+	Py_ssize_t len = PyBytes_GET_SIZE(self), n, i, j;
 	Py_ssize_t maxsplit = -1, count=0;
-	const char *s = PyString_AS_STRING(self), *sub;
+	const char *s = PyBytes_AS_STRING(self), *sub;
 	Py_buffer vsub;
 	PyObject *list, *str, *subobj = Py_None;
 #ifdef USE_FAST
@@ -1216,21 +1216,21 @@
 found, returns B and two empty bytes objects.");
 
 static PyObject *
-string_partition(PyStringObject *self, PyObject *sep_obj)
+string_partition(PyBytesObject *self, PyObject *sep_obj)
 {
 	const char *sep;
 	Py_ssize_t sep_len;
 
-	if (PyString_Check(sep_obj)) {
-		sep = PyString_AS_STRING(sep_obj);
-		sep_len = PyString_GET_SIZE(sep_obj);
+	if (PyBytes_Check(sep_obj)) {
+		sep = PyBytes_AS_STRING(sep_obj);
+		sep_len = PyBytes_GET_SIZE(sep_obj);
 	}
 	else if (PyObject_AsCharBuffer(sep_obj, &sep, &sep_len))
 		return NULL;
 
 	return stringlib_partition(
 		(PyObject*) self,
-		PyString_AS_STRING(self), PyString_GET_SIZE(self),
+		PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self),
 		sep_obj, sep, sep_len
 		);
 }
@@ -1244,29 +1244,29 @@
 bytes objects and B.");
 
 static PyObject *
-string_rpartition(PyStringObject *self, PyObject *sep_obj)
+string_rpartition(PyBytesObject *self, PyObject *sep_obj)
 {
 	const char *sep;
 	Py_ssize_t sep_len;
 
-	if (PyString_Check(sep_obj)) {
-		sep = PyString_AS_STRING(sep_obj);
-		sep_len = PyString_GET_SIZE(sep_obj);
+	if (PyBytes_Check(sep_obj)) {
+		sep = PyBytes_AS_STRING(sep_obj);
+		sep_len = PyBytes_GET_SIZE(sep_obj);
 	}
 	else if (PyObject_AsCharBuffer(sep_obj, &sep, &sep_len))
 		return NULL;
 
 	return stringlib_rpartition(
 		(PyObject*) self,
-		PyString_AS_STRING(self), PyString_GET_SIZE(self),
+		PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self),
 		sep_obj, sep, sep_len
 		);
 }
 
 Py_LOCAL_INLINE(PyObject *)
-rsplit_whitespace(PyStringObject *self, Py_ssize_t len, Py_ssize_t maxsplit)
+rsplit_whitespace(PyBytesObject *self, Py_ssize_t len, Py_ssize_t maxsplit)
 {
-	const char *s = PyString_AS_STRING(self);
+	const char *s = PyBytes_AS_STRING(self);
 	Py_ssize_t i, j, count=0;
 	PyObject *str;
 	PyObject *list = PyList_New(PREALLOC_SIZE(maxsplit));
@@ -1281,7 +1281,7 @@
 		if (i<0) break;
 		j = i; i--;
 		RSKIP_NONSPACE(s, i);
-		if (j == len-1 && i < 0 && PyString_CheckExact(self)) {
+		if (j == len-1 && i < 0 && PyBytes_CheckExact(self)) {
 			/* No whitespace in self, so just use it as list[0] */
 			Py_INCREF(self);
 			PyList_SET_ITEM(list, 0, (PyObject *)self);
@@ -1308,9 +1308,9 @@
 }
 
 Py_LOCAL_INLINE(PyObject *)
-rsplit_char(PyStringObject *self, Py_ssize_t len, char ch, Py_ssize_t maxcount)
+rsplit_char(PyBytesObject *self, Py_ssize_t len, char ch, Py_ssize_t maxcount)
 {
-	const char *s = PyString_AS_STRING(self);
+	const char *s = PyBytes_AS_STRING(self);
 	register Py_ssize_t i, j, count=0;
 	PyObject *str;
 	PyObject *list = PyList_New(PREALLOC_SIZE(maxcount));
@@ -1328,7 +1328,7 @@
 			}
 		}
 	}
-	if (i < 0 && count == 0 && PyString_CheckExact(self)) {
+	if (i < 0 && count == 0 && PyBytes_CheckExact(self)) {
 		/* ch not in self, so just use self as list[0] */
 		Py_INCREF(self);
 		PyList_SET_ITEM(list, 0, (PyObject *)self);
@@ -1358,9 +1358,9 @@
 
 
 static PyObject *
-string_rsplit(PyStringObject *self, PyObject *args)
+string_rsplit(PyBytesObject *self, PyObject *args)
 {
-	Py_ssize_t len = PyString_GET_SIZE(self), n, i, j;
+	Py_ssize_t len = PyBytes_GET_SIZE(self), n, i, j;
 	Py_ssize_t maxsplit = -1, count=0;
 	const char *s, *sub;
 	Py_buffer vsub;
@@ -1394,7 +1394,7 @@
 	j = len;
 	i = j - n;
 
-	s = PyString_AS_STRING(self);
+	s = PyBytes_AS_STRING(self);
 	while ( (i >= 0) && (maxsplit-- > 0) ) {
 		for (; i>=0; i--) {
 			if (Py_STRING_MATCH(s, i, sub, n)) {
@@ -1432,8 +1432,8 @@
 static PyObject *
 string_join(PyObject *self, PyObject *orig)
 {
-	char *sep = PyString_AS_STRING(self);
-	const Py_ssize_t seplen = PyString_GET_SIZE(self);
+	char *sep = PyBytes_AS_STRING(self);
+	const Py_ssize_t seplen = PyBytes_GET_SIZE(self);
 	PyObject *res = NULL;
 	char *p;
 	Py_ssize_t seqlen = 0;
@@ -1449,11 +1449,11 @@
 	seqlen = PySequence_Size(seq);
 	if (seqlen == 0) {
 		Py_DECREF(seq);
-		return PyString_FromString("");
+		return PyBytes_FromString("");
 	}
 	if (seqlen == 1) {
 		item = PySequence_Fast_GET_ITEM(seq, 0);
-		if (PyString_CheckExact(item)) {
+		if (PyBytes_CheckExact(item)) {
 			Py_INCREF(item);
 			Py_DECREF(seq);
 			return item;
@@ -1469,7 +1469,7 @@
 	for (i = 0; i < seqlen; i++) {
 		const size_t old_sz = sz;
 		item = PySequence_Fast_GET_ITEM(seq, i);
-		if (!PyString_Check(item) && !PyByteArray_Check(item)) {
+		if (!PyBytes_Check(item) && !PyByteArray_Check(item)) {
 			PyErr_Format(PyExc_TypeError,
 				     "sequence item %zd: expected bytes,"
 				     " %.80s found",
@@ -1489,7 +1489,7 @@
 	}
 
 	/* Allocate result space. */
-	res = PyString_FromStringAndSize((char*)NULL, sz);
+	res = PyBytes_FromStringAndSize((char*)NULL, sz);
 	if (res == NULL) {
 		Py_DECREF(seq);
 		return NULL;
@@ -1498,7 +1498,7 @@
 	/* Catenate everything. */
 	/* I'm not worried about a PyByteArray item growing because there's
 	   nowhere in this function where we release the GIL. */
-	p = PyString_AS_STRING(res);
+	p = PyBytes_AS_STRING(res);
 	for (i = 0; i < seqlen; ++i) {
 		size_t n;
                 char *q;
@@ -1508,8 +1508,8 @@
 		}
 		item = PySequence_Fast_GET_ITEM(seq, i);
 		n = Py_SIZE(item);
-                if (PyString_Check(item))
-			q = PyString_AS_STRING(item);
+                if (PyBytes_Check(item))
+			q = PyBytes_AS_STRING(item);
 		else
 			q = PyByteArray_AS_STRING(item);
 		Py_MEMCPY(p, q, n);
@@ -1521,9 +1521,9 @@
 }
 
 PyObject *
-_PyString_Join(PyObject *sep, PyObject *x)
+_PyBytes_Join(PyObject *sep, PyObject *x)
 {
-	assert(sep != NULL && PyString_Check(sep));
+	assert(sep != NULL && PyBytes_Check(sep));
 	assert(x != NULL);
 	return string_join(sep, x);
 }
@@ -1544,7 +1544,7 @@
 }
 
 Py_LOCAL_INLINE(Py_ssize_t)
-string_find_internal(PyStringObject *self, PyObject *args, int dir)
+string_find_internal(PyBytesObject *self, PyObject *args, int dir)
 {
 	PyObject *subobj;
 	const char *sub;
@@ -1565,9 +1565,9 @@
 		if (!_PyEval_SliceIndex(obj_end, &end))
 	        return -2;
 
-	if (PyString_Check(subobj)) {
-		sub = PyString_AS_STRING(subobj);
-		sub_len = PyString_GET_SIZE(subobj);
+	if (PyBytes_Check(subobj)) {
+		sub = PyBytes_AS_STRING(subobj);
+		sub_len = PyBytes_GET_SIZE(subobj);
 	}
 	else if (PyObject_AsCharBuffer(subobj, &sub, &sub_len))
 		/* XXX - the "expected a character buffer object" is pretty
@@ -1576,11 +1576,11 @@
 
 	if (dir > 0)
 		return stringlib_find_slice(
-			PyString_AS_STRING(self), PyString_GET_SIZE(self),
+			PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self),
 			sub, sub_len, start, end);
 	else
 		return stringlib_rfind_slice(
-			PyString_AS_STRING(self), PyString_GET_SIZE(self),
+			PyBytes_AS_STRING(self), PyBytes_GET_SIZE(self),
 			sub, sub_len, start, end);
 }
 
@@ -1595,7 +1595,7 @@
 Return -1 on failure.");
 
 static PyObject *
-string_find(PyStringObject *self, PyObject *args)
+string_find(PyBytesObject *self, PyObject *args)
 {
 	Py_ssize_t result = string_find_internal(self, args, +1);
 	if (result == -2)
@@ -1610,7 +1610,7 @@
 Like B.find() but raise ValueError when the substring is not found.");
 
 static PyObject *
-string_index(PyStringObject *self, PyObject *args)
+string_index(PyBytesObject *self, PyObject *args)
 {
 	Py_ssize_t result = string_find_internal(self, args, +1);
 	if (result == -2)
@@ -1634,7 +1634,7 @@
 Return -1 on failure.");
 
 static PyObject *
-string_rfind(PyStringObject *self, PyObject *args)
+string_rfind(PyBytesObject *self, PyObject *args)
 {
 	Py_ssize_t result = string_find_internal(self, args, -1);
 	if (result == -2)
@@ -1649,7 +1649,7 @@
 Like B.rfind() but raise ValueError when the substring is not found.");
 
 static PyObject *
-string_rindex(PyStringObject *self, PyObject *args)
+string_rindex(PyBytesObject *self, PyObject *args)
 {
 	Py_ssize_t result = string_find_internal(self, args, -1);
 	if (result == -2)
@@ -1664,11 +1664,11 @@
 
 
 Py_LOCAL_INLINE(PyObject *)
-do_xstrip(PyStringObject *self, int striptype, PyObject *sepobj)
+do_xstrip(PyBytesObject *self, int striptype, PyObject *sepobj)
 {
 	Py_buffer vsep;
-	char *s = PyString_AS_STRING(self);
-	Py_ssize_t len = PyString_GET_SIZE(self);
+	char *s = PyBytes_AS_STRING(self);
+	Py_ssize_t len = PyBytes_GET_SIZE(self);
 	char *sep;
 	Py_ssize_t seplen;
 	Py_ssize_t i, j;
@@ -1695,20 +1695,20 @@
 
 	PyObject_ReleaseBuffer(sepobj, &vsep);
 
-	if (i == 0 && j == len && PyString_CheckExact(self)) {
+	if (i == 0 && j == len && PyBytes_CheckExact(self)) {
 		Py_INCREF(self);
 		return (PyObject*)self;
 	}
 	else
-		return PyString_FromStringAndSize(s+i, j-i);
+		return PyBytes_FromStringAndSize(s+i, j-i);
 }
 
 
 Py_LOCAL_INLINE(PyObject *)
-do_strip(PyStringObject *self, int striptype)
+do_strip(PyBytesObject *self, int striptype)
 {
-	char *s = PyString_AS_STRING(self);
-	Py_ssize_t len = PyString_GET_SIZE(self), i, j;
+	char *s = PyBytes_AS_STRING(self);
+	Py_ssize_t len = PyBytes_GET_SIZE(self), i, j;
 
 	i = 0;
 	if (striptype != RIGHTSTRIP) {
@@ -1725,17 +1725,17 @@
 		j++;
 	}
 
-	if (i == 0 && j == len && PyString_CheckExact(self)) {
+	if (i == 0 && j == len && PyBytes_CheckExact(self)) {
 		Py_INCREF(self);
 		return (PyObject*)self;
 	}
 	else
-		return PyString_FromStringAndSize(s+i, j-i);
+		return PyBytes_FromStringAndSize(s+i, j-i);
 }
 
 
 Py_LOCAL_INLINE(PyObject *)
-do_argstrip(PyStringObject *self, int striptype, PyObject *args)
+do_argstrip(PyBytesObject *self, int striptype, PyObject *args)
 {
 	PyObject *sep = NULL;
 
@@ -1755,7 +1755,7 @@
 Strip leading and trailing bytes contained in the argument.\n\
 If the argument is omitted, strip trailing ASCII whitespace.");
 static PyObject *
-string_strip(PyStringObject *self, PyObject *args)
+string_strip(PyBytesObject *self, PyObject *args)
 {
 	if (PyTuple_GET_SIZE(args) == 0)
 		return do_strip(self, BOTHSTRIP); /* Common case */
@@ -1770,7 +1770,7 @@
 Strip leading bytes contained in the argument.\n\
 If the argument is omitted, strip leading ASCII whitespace.");
 static PyObject *
-string_lstrip(PyStringObject *self, PyObject *args)
+string_lstrip(PyBytesObject *self, PyObject *args)
 {
 	if (PyTuple_GET_SIZE(args) == 0)
 		return do_strip(self, LEFTSTRIP); /* Common case */
@@ -1785,7 +1785,7 @@
 Strip trailing bytes contained in the argument.\n\
 If the argument is omitted, strip trailing ASCII whitespace.");
 static PyObject *
-string_rstrip(PyStringObject *self, PyObject *args)
+string_rstrip(PyBytesObject *self, PyObject *args)
 {
 	if (PyTuple_GET_SIZE(args) == 0)
 		return do_strip(self, RIGHTSTRIP); /* Common case */
@@ -1802,10 +1802,10 @@
 as in slice notation.");
 
 static PyObject *
-string_count(PyStringObject *self, PyObject *args)
+string_count(PyBytesObject *self, PyObject *args)
 {
 	PyObject *sub_obj;
-	const char *str = PyString_AS_STRING(self), *sub;
+	const char *str = PyBytes_AS_STRING(self), *sub;
 	Py_ssize_t sub_len;
 	Py_ssize_t start = 0, end = PY_SSIZE_T_MAX;
 
@@ -1813,14 +1813,14 @@
 		_PyEval_SliceIndex, &start, _PyEval_SliceIndex, &end))
 		return NULL;
 
-	if (PyString_Check(sub_obj)) {
-		sub = PyString_AS_STRING(sub_obj);
-		sub_len = PyString_GET_SIZE(sub_obj);
+	if (PyBytes_Check(sub_obj)) {
+		sub = PyBytes_AS_STRING(sub_obj);
+		sub_len = PyBytes_GET_SIZE(sub_obj);
 	}
 	else if (PyObject_AsCharBuffer(sub_obj, &sub, &sub_len))
 		return NULL;
 
-	string_adjust_indices(&start, &end, PyString_GET_SIZE(self));
+	string_adjust_indices(&start, &end, PyBytes_GET_SIZE(self));
 
 	return PyLong_FromSsize_t(
 		stringlib_count(str + start, end - start, sub, sub_len)
@@ -1837,7 +1837,7 @@
 table, which must be a bytes object of length 256.");
 
 static PyObject *
-string_translate(PyStringObject *self, PyObject *args)
+string_translate(PyBytesObject *self, PyObject *args)
 {
 	register char *input, *output;
 	const char *table;
@@ -1853,9 +1853,9 @@
 			      &tableobj, &delobj))
 		return NULL;
 
-	if (PyString_Check(tableobj)) {
-		table = PyString_AS_STRING(tableobj);
-		tablen = PyString_GET_SIZE(tableobj);
+	if (PyBytes_Check(tableobj)) {
+		table = PyBytes_AS_STRING(tableobj);
+		tablen = PyBytes_GET_SIZE(tableobj);
 	}
 	else if (tableobj == Py_None) {
 		table = NULL;
@@ -1871,9 +1871,9 @@
 	}
 
 	if (delobj != NULL) {
-		if (PyString_Check(delobj)) {
-			del_table = PyString_AS_STRING(delobj);
-			dellen = PyString_GET_SIZE(delobj);
+		if (PyBytes_Check(delobj)) {
+			del_table = PyBytes_AS_STRING(delobj);
+			dellen = PyBytes_GET_SIZE(delobj);
 		}
 		else if (PyUnicode_Check(delobj)) {
 			PyErr_SetString(PyExc_TypeError,
@@ -1888,12 +1888,12 @@
 		dellen = 0;
 	}
 
-	inlen = PyString_GET_SIZE(input_obj);
-	result = PyString_FromStringAndSize((char *)NULL, inlen);
+	inlen = PyBytes_GET_SIZE(input_obj);
+	result = PyBytes_FromStringAndSize((char *)NULL, inlen);
 	if (result == NULL)
 		return NULL;
-	output_start = output = PyString_AsString(result);
-	input = PyString_AS_STRING(input_obj);
+	output_start = output = PyBytes_AsString(result);
+	input = PyBytes_AS_STRING(input_obj);
 
 	if (dellen == 0 && table != NULL) {
 		/* If no deletions are required, use faster code */
@@ -1902,7 +1902,7 @@
 			if (Py_CHARMASK((*output++ = table[c])) != c)
 				changed = 1;
 		}
-		if (changed || !PyString_CheckExact(input_obj))
+		if (changed || !PyBytes_CheckExact(input_obj))
 			return result;
 		Py_DECREF(result);
 		Py_INCREF(input_obj);
@@ -1927,14 +1927,14 @@
 				continue;
 		changed = 1;
 	}
-	if (!changed && PyString_CheckExact(input_obj)) {
+	if (!changed && PyBytes_CheckExact(input_obj)) {
 		Py_DECREF(result);
 		Py_INCREF(input_obj);
 		return input_obj;
 	}
 	/* Fix the size of the resulting string */
 	if (inlen > 0)
-		_PyString_Resize(&result, output - output_start);
+		_PyBytes_Resize(&result, output - output_start);
 	return result;
 }
 
@@ -1949,16 +1949,16 @@
 
 /* String ops must return a string.  */
 /* If the object is subclass of string, create a copy */
-Py_LOCAL(PyStringObject *)
-return_self(PyStringObject *self)
+Py_LOCAL(PyBytesObject *)
+return_self(PyBytesObject *self)
 {
-	if (PyString_CheckExact(self)) {
+	if (PyBytes_CheckExact(self)) {
 		Py_INCREF(self);
 		return self;
 	}
-	return (PyStringObject *)PyString_FromStringAndSize(
-		PyString_AS_STRING(self),
-		PyString_GET_SIZE(self));
+	return (PyBytesObject *)PyBytes_FromStringAndSize(
+		PyBytes_AS_STRING(self),
+		PyBytes_GET_SIZE(self));
 }
 
 Py_LOCAL_INLINE(Py_ssize_t)
@@ -2069,17 +2069,17 @@
 /* Algorithms for different cases of string replacement */
 
 /* len(self)>=1, from="", len(to)>=1, maxcount>=1 */
-Py_LOCAL(PyStringObject *)
-replace_interleave(PyStringObject *self,
+Py_LOCAL(PyBytesObject *)
+replace_interleave(PyBytesObject *self,
 		   const char *to_s, Py_ssize_t to_len,
 		   Py_ssize_t maxcount)
 {
 	char *self_s, *result_s;
 	Py_ssize_t self_len, result_len;
 	Py_ssize_t count, i, product;
-	PyStringObject *result;
+	PyBytesObject *result;
 
-	self_len = PyString_GET_SIZE(self);
+	self_len = PyBytes_GET_SIZE(self);
 
 	/* 1 at the end plus 1 after every character */
 	count = self_len+1;
@@ -2101,12 +2101,12 @@
 		return NULL;
 	}
 
-	if (! (result = (PyStringObject *)
-	                 PyString_FromStringAndSize(NULL, result_len)) )
+	if (! (result = (PyBytesObject *)
+	                 PyBytes_FromStringAndSize(NULL, result_len)) )
 		return NULL;
 
-	self_s = PyString_AS_STRING(self);
-	result_s = PyString_AS_STRING(result);
+	self_s = PyBytes_AS_STRING(self);
+	result_s = PyBytes_AS_STRING(result);
 
 	/* TODO: special case single character, which doesn't need memcpy */
 
@@ -2129,18 +2129,18 @@
 
 /* Special case for deleting a single character */
 /* len(self)>=1, len(from)==1, to="", maxcount>=1 */
-Py_LOCAL(PyStringObject *)
-replace_delete_single_character(PyStringObject *self,
+Py_LOCAL(PyBytesObject *)
+replace_delete_single_character(PyBytesObject *self,
 				char from_c, Py_ssize_t maxcount)
 {
 	char *self_s, *result_s;
 	char *start, *next, *end;
 	Py_ssize_t self_len, result_len;
 	Py_ssize_t count;
-	PyStringObject *result;
+	PyBytesObject *result;
 
-	self_len = PyString_GET_SIZE(self);
-	self_s = PyString_AS_STRING(self);
+	self_len = PyBytes_GET_SIZE(self);
+	self_s = PyBytes_AS_STRING(self);
 
 	count = countchar(self_s, self_len, from_c, maxcount);
 	if (count == 0) {
@@ -2150,10 +2150,10 @@
 	result_len = self_len - count;  /* from_len == 1 */
 	assert(result_len>=0);
 
-	if ( (result = (PyStringObject *)
-	                PyString_FromStringAndSize(NULL, result_len)) == NULL)
+	if ( (result = (PyBytesObject *)
+	                PyBytes_FromStringAndSize(NULL, result_len)) == NULL)
 		return NULL;
-	result_s = PyString_AS_STRING(result);
+	result_s = PyBytes_AS_STRING(result);
 
 	start = self_s;
 	end = self_s + self_len;
@@ -2172,18 +2172,18 @@
 
 /* len(self)>=1, len(from)>=2, to="", maxcount>=1 */
 
-Py_LOCAL(PyStringObject *)
-replace_delete_substring(PyStringObject *self,
+Py_LOCAL(PyBytesObject *)
+replace_delete_substring(PyBytesObject *self,
 			 const char *from_s, Py_ssize_t from_len,
 			 Py_ssize_t maxcount) {
 	char *self_s, *result_s;
 	char *start, *next, *end;
 	Py_ssize_t self_len, result_len;
 	Py_ssize_t count, offset;
-	PyStringObject *result;
+	PyBytesObject *result;
 
-	self_len = PyString_GET_SIZE(self);
-	self_s = PyString_AS_STRING(self);
+	self_len = PyBytes_GET_SIZE(self);
+	self_s = PyBytes_AS_STRING(self);
 
 	count = countstring(self_s, self_len,
 			    from_s, from_len,
@@ -2198,11 +2198,11 @@
 	result_len = self_len - (count * from_len);
 	assert (result_len>=0);
 
-	if ( (result = (PyStringObject *)
-	      PyString_FromStringAndSize(NULL, result_len)) == NULL )
+	if ( (result = (PyBytesObject *)
+	      PyBytes_FromStringAndSize(NULL, result_len)) == NULL )
 		return NULL;
 
-	result_s = PyString_AS_STRING(result);
+	result_s = PyBytes_AS_STRING(result);
 
 	start = self_s;
 	end = self_s + self_len;
@@ -2224,18 +2224,18 @@
 }
 
 /* len(self)>=1, len(from)==len(to)==1, maxcount>=1 */
-Py_LOCAL(PyStringObject *)
-replace_single_character_in_place(PyStringObject *self,
+Py_LOCAL(PyBytesObject *)
+replace_single_character_in_place(PyBytesObject *self,
 				  char from_c, char to_c,
 				  Py_ssize_t maxcount)
 {
 	char *self_s, *result_s, *start, *end, *next;
 	Py_ssize_t self_len;
-	PyStringObject *result;
+	PyBytesObject *result;
 
 	/* The result string will be the same size */
-	self_s = PyString_AS_STRING(self);
-	self_len = PyString_GET_SIZE(self);
+	self_s = PyBytes_AS_STRING(self);
+	self_len = PyBytes_GET_SIZE(self);
 
 	next = findchar(self_s, self_len, from_c);
 
@@ -2245,10 +2245,10 @@
 	}
 
 	/* Need to make a new string */
-	result = (PyStringObject *) PyString_FromStringAndSize(NULL, self_len);
+	result = (PyBytesObject *) PyBytes_FromStringAndSize(NULL, self_len);
 	if (result == NULL)
 		return NULL;
-	result_s = PyString_AS_STRING(result);
+	result_s = PyBytes_AS_STRING(result);
 	Py_MEMCPY(result_s, self_s, self_len);
 
 	/* change everything in-place, starting with this one */
@@ -2269,8 +2269,8 @@
 }
 
 /* len(self)>=1, len(from)==len(to)>=2, maxcount>=1 */
-Py_LOCAL(PyStringObject *)
-replace_substring_in_place(PyStringObject *self,
+Py_LOCAL(PyBytesObject *)
+replace_substring_in_place(PyBytesObject *self,
 			   const char *from_s, Py_ssize_t from_len,
 			   const char *to_s, Py_ssize_t to_len,
 			   Py_ssize_t maxcount)
@@ -2278,12 +2278,12 @@
 	char *result_s, *start, *end;
 	char *self_s;
 	Py_ssize_t self_len, offset;
-	PyStringObject *result;
+	PyBytesObject *result;
 
 	/* The result string will be the same size */
 
-	self_s = PyString_AS_STRING(self);
-	self_len = PyString_GET_SIZE(self);
+	self_s = PyBytes_AS_STRING(self);
+	self_len = PyBytes_GET_SIZE(self);
 
 	offset = findstring(self_s, self_len,
 			    from_s, from_len,
@@ -2294,10 +2294,10 @@
 	}
 
 	/* Need to make a new string */
-	result = (PyStringObject *) PyString_FromStringAndSize(NULL, self_len);
+	result = (PyBytesObject *) PyBytes_FromStringAndSize(NULL, self_len);
 	if (result == NULL)
 		return NULL;
-	result_s = PyString_AS_STRING(result);
+	result_s = PyBytes_AS_STRING(result);
 	Py_MEMCPY(result_s, self_s, self_len);
 
 	/* change everything in-place, starting with this one */
@@ -2320,8 +2320,8 @@
 }
 
 /* len(self)>=1, len(from)==1, len(to)>=2, maxcount>=1 */
-Py_LOCAL(PyStringObject *)
-replace_single_character(PyStringObject *self,
+Py_LOCAL(PyBytesObject *)
+replace_single_character(PyBytesObject *self,
 			 char from_c,
 			 const char *to_s, Py_ssize_t to_len,
 			 Py_ssize_t maxcount)
@@ -2330,10 +2330,10 @@
 	char *start, *next, *end;
 	Py_ssize_t self_len, result_len;
 	Py_ssize_t count, product;
-	PyStringObject *result;
+	PyBytesObject *result;
 
-	self_s = PyString_AS_STRING(self);
-	self_len = PyString_GET_SIZE(self);
+	self_s = PyBytes_AS_STRING(self);
+	self_len = PyBytes_GET_SIZE(self);
 
 	count = countchar(self_s, self_len, from_c, maxcount);
 	if (count == 0) {
@@ -2356,10 +2356,10 @@
 		return NULL;
 	}
 
-	if ( (result = (PyStringObject *)
-	      PyString_FromStringAndSize(NULL, result_len)) == NULL)
+	if ( (result = (PyBytesObject *)
+	      PyBytes_FromStringAndSize(NULL, result_len)) == NULL)
 		return NULL;
-	result_s = PyString_AS_STRING(result);
+	result_s = PyBytes_AS_STRING(result);
 
 	start = self_s;
 	end = self_s + self_len;
@@ -2389,8 +2389,8 @@
 }
 
 /* len(self)>=1, len(from)>=2, len(to)>=2, maxcount>=1 */
-Py_LOCAL(PyStringObject *)
-replace_substring(PyStringObject *self,
+Py_LOCAL(PyBytesObject *)
+replace_substring(PyBytesObject *self,
 		  const char *from_s, Py_ssize_t from_len,
 		  const char *to_s, Py_ssize_t to_len,
 		  Py_ssize_t maxcount) {
@@ -2398,10 +2398,10 @@
 	char *start, *next, *end;
 	Py_ssize_t self_len, result_len;
 	Py_ssize_t count, offset, product;
-	PyStringObject *result;
+	PyBytesObject *result;
 
-	self_s = PyString_AS_STRING(self);
-	self_len = PyString_GET_SIZE(self);
+	self_s = PyBytes_AS_STRING(self);
+	self_len = PyBytes_GET_SIZE(self);
 
 	count = countstring(self_s, self_len,
 			    from_s, from_len,
@@ -2426,10 +2426,10 @@
 		return NULL;
 	}
 
-	if ( (result = (PyStringObject *)
-	      PyString_FromStringAndSize(NULL, result_len)) == NULL)
+	if ( (result = (PyBytesObject *)
+	      PyBytes_FromStringAndSize(NULL, result_len)) == NULL)
 		return NULL;
-	result_s = PyString_AS_STRING(result);
+	result_s = PyBytes_AS_STRING(result);
 
 	start = self_s;
 	end = self_s + self_len;
@@ -2461,15 +2461,15 @@
 }
 
 
-Py_LOCAL(PyStringObject *)
-replace(PyStringObject *self,
+Py_LOCAL(PyBytesObject *)
+replace(PyBytesObject *self,
 	const char *from_s, Py_ssize_t from_len,
 	const char *to_s, Py_ssize_t to_len,
 	Py_ssize_t maxcount)
 {
 	if (maxcount < 0) {
 		maxcount = PY_SSIZE_T_MAX;
-	} else if (maxcount == 0 || PyString_GET_SIZE(self) == 0) {
+	} else if (maxcount == 0 || PyBytes_GET_SIZE(self) == 0) {
 		/* nothing to do; return the original string */
 		return return_self(self);
 	}
@@ -2492,7 +2492,7 @@
 	/* Except for "".replace("", "A") == "A" there is no way beyond this */
 	/* point for an empty self string to generate a non-empty string */
 	/* Special case so the remaining code always gets a non-empty string */
-	if (PyString_GET_SIZE(self) == 0) {
+	if (PyBytes_GET_SIZE(self) == 0) {
 		return return_self(self);
 	}
 
@@ -2542,7 +2542,7 @@
 given, only the first count occurrences are replaced.");
 
 static PyObject *
-string_replace(PyStringObject *self, PyObject *args)
+string_replace(PyBytesObject *self, PyObject *args)
 {
 	Py_ssize_t count = -1;
 	PyObject *from, *to;
@@ -2552,21 +2552,21 @@
 	if (!PyArg_ParseTuple(args, "OO|n:replace", &from, &to, &count))
 		return NULL;
 
-	if (PyString_Check(from)) {
-		from_s = PyString_AS_STRING(from);
-		from_len = PyString_GET_SIZE(from);
+	if (PyBytes_Check(from)) {
+		from_s = PyBytes_AS_STRING(from);
+		from_len = PyBytes_GET_SIZE(from);
 	}
 	else if (PyObject_AsCharBuffer(from, &from_s, &from_len))
 		return NULL;
 
-	if (PyString_Check(to)) {
-		to_s = PyString_AS_STRING(to);
-		to_len = PyString_GET_SIZE(to);
+	if (PyBytes_Check(to)) {
+		to_s = PyBytes_AS_STRING(to);
+		to_len = PyBytes_GET_SIZE(to);
 	}
 	else if (PyObject_AsCharBuffer(to, &to_s, &to_len))
 		return NULL;
 
-	return (PyObject *)replace((PyStringObject *) self,
+	return (PyObject *)replace((PyBytesObject *) self,
 				   from_s, from_len,
 				   to_s, to_len, count);
 }
@@ -2578,21 +2578,21 @@
  * -1 on error, 0 if not found and 1 if found.
  */
 Py_LOCAL(int)
-_string_tailmatch(PyStringObject *self, PyObject *substr, Py_ssize_t start,
+_string_tailmatch(PyBytesObject *self, PyObject *substr, Py_ssize_t start,
 		  Py_ssize_t end, int direction)
 {
-	Py_ssize_t len = PyString_GET_SIZE(self);
+	Py_ssize_t len = PyBytes_GET_SIZE(self);
 	Py_ssize_t slen;
 	const char* sub;
 	const char* str;
 
-	if (PyString_Check(substr)) {
-		sub = PyString_AS_STRING(substr);
-		slen = PyString_GET_SIZE(substr);
+	if (PyBytes_Check(substr)) {
+		sub = PyBytes_AS_STRING(substr);
+		slen = PyBytes_GET_SIZE(substr);
 	}
 	else if (PyObject_AsCharBuffer(substr, &sub, &slen))
 		return -1;
-	str = PyString_AS_STRING(self);
+	str = PyBytes_AS_STRING(self);
 
 	string_adjust_indices(&start, &end, len);
 
@@ -2623,7 +2623,7 @@
 prefix can also be a tuple of strings to try.");
 
 static PyObject *
-string_startswith(PyStringObject *self, PyObject *args)
+string_startswith(PyBytesObject *self, PyObject *args)
 {
 	Py_ssize_t start = 0;
 	Py_ssize_t end = PY_SSIZE_T_MAX;
@@ -2664,7 +2664,7 @@
 suffix can also be a tuple of strings to try.");
 
 static PyObject *
-string_endswith(PyStringObject *self, PyObject *args)
+string_endswith(PyBytesObject *self, PyObject *args)
 {
 	Py_ssize_t start = 0;
 	Py_ssize_t end = PY_SSIZE_T_MAX;
@@ -2758,10 +2758,10 @@
 	hexlen = PyUnicode_GET_SIZE(hexobj);
 	hex = PyUnicode_AS_UNICODE(hexobj);
 	byteslen = hexlen/2; /* This overestimates if there are spaces */
-	newstring = PyString_FromStringAndSize(NULL, byteslen);
+	newstring = PyBytes_FromStringAndSize(NULL, byteslen);
 	if (!newstring)
 		return NULL;
-	buf = PyString_AS_STRING(newstring);
+	buf = PyBytes_AS_STRING(newstring);
 	for (i = j = 0; i < hexlen; i += 2) {
 		/* skip over spaces in the input */
 		while (hex[i] == ' ')
@@ -2778,7 +2778,7 @@
 		}
 		buf[j++] = (top << 4) + bot;
 	}
-	if (j != byteslen && _PyString_Resize(&newstring, j) < 0)
+	if (j != byteslen && _PyBytes_Resize(&newstring, j) < 0)
 		goto error;
 	return newstring;
 
@@ -2789,7 +2789,7 @@
 
 
 static PyObject *
-string_getnewargs(PyStringObject *v)
+string_getnewargs(PyBytesObject *v)
 {
 	return Py_BuildValue("(s#)", v->ob_sval, Py_SIZE(v));
 }
@@ -2867,7 +2867,7 @@
 	Py_ssize_t i, size;
 	static char *kwlist[] = {"source", "encoding", "errors", 0};
 
-	if (type != &PyString_Type)
+	if (type != &PyBytes_Type)
 		return str_subtype_new(type, args, kwds);
 	if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oss:bytes", kwlist, &x,
 					 &encoding, &errors))
@@ -2879,7 +2879,7 @@
 					"argument");
 			return NULL;
 		}
-		return PyString_FromString("");
+		return PyBytes_FromString("");
 	}
 
 	if (PyUnicode_Check(x)) {
@@ -2892,7 +2892,7 @@
 		new = PyCodec_Encode(x, encoding, errors);
 		if (new == NULL)
 			return NULL;
-		assert(PyString_Check(new));
+		assert(PyBytes_Check(new));
 		return new;
 	}
 
@@ -2913,12 +2913,12 @@
 			PyErr_SetString(PyExc_ValueError, "negative count");
 			return NULL;
 		}
-		new = PyString_FromStringAndSize(NULL, size);
+		new = PyBytes_FromStringAndSize(NULL, size);
 		if (new == NULL) {
 			return NULL;
 		}
 		if (size > 0) {
-			memset(((PyStringObject*)new)->ob_sval, 0, size);
+			memset(((PyBytesObject*)new)->ob_sval, 0, size);
 		}
 		return new;
 	}
@@ -2928,11 +2928,11 @@
 		Py_buffer view;
 		if (PyObject_GetBuffer(x, &view, PyBUF_FULL_RO) < 0)
 			return NULL;
-		new = PyString_FromStringAndSize(NULL, view.len);
+		new = PyBytes_FromStringAndSize(NULL, view.len);
 		if (!new)
 			goto fail;
 		// XXX(brett.cannon): Better way to get to internal buffer?
-		if (PyBuffer_ToContiguous(((PyStringObject *)new)->ob_sval,
+		if (PyBuffer_ToContiguous(((PyBytesObject *)new)->ob_sval,
 					  &view, view.len, 'C') < 0)
 			goto fail;
 		PyObject_ReleaseBuffer(x, &view);
@@ -2948,7 +2948,7 @@
 	/* XXX(guido): perhaps use Pysequence_Fast() -- I can't imagine the
 	   input being a truly long iterator. */
 	size = 64;
-	new = PyString_FromStringAndSize(NULL, size);
+	new = PyBytes_FromStringAndSize(NULL, size);
 	if (new == NULL)
 		return NULL;
 
@@ -2988,12 +2988,12 @@
 		/* Append the byte */
 		if (i >= size) {
 			size *= 2;
-			if (_PyString_Resize(&new, size) < 0)
+			if (_PyBytes_Resize(&new, size) < 0)
 				goto error;
 		}
-		((PyStringObject *)new)->ob_sval[i] = value;
+		((PyBytesObject *)new)->ob_sval[i] = value;
 	}
-	_PyString_Resize(&new, i);
+	_PyBytes_Resize(&new, i);
 
 	/* Clean up and return success */
 	Py_DECREF(it);
@@ -3012,18 +3012,18 @@
 	PyObject *tmp, *pnew;
 	Py_ssize_t n;
 
-	assert(PyType_IsSubtype(type, &PyString_Type));
-	tmp = string_new(&PyString_Type, args, kwds);
+	assert(PyType_IsSubtype(type, &PyBytes_Type));
+	tmp = string_new(&PyBytes_Type, args, kwds);
 	if (tmp == NULL)
 		return NULL;
-	assert(PyString_CheckExact(tmp));
-	n = PyString_GET_SIZE(tmp);
+	assert(PyBytes_CheckExact(tmp));
+	n = PyBytes_GET_SIZE(tmp);
 	pnew = type->tp_alloc(type, n);
 	if (pnew != NULL) {
-		Py_MEMCPY(PyString_AS_STRING(pnew),
-			  PyString_AS_STRING(tmp), n+1);
-		((PyStringObject *)pnew)->ob_shash =
-			((PyStringObject *)tmp)->ob_shash;
+		Py_MEMCPY(PyBytes_AS_STRING(pnew),
+			  PyBytes_AS_STRING(tmp), n+1);
+		((PyBytesObject *)pnew)->ob_shash =
+			((PyBytesObject *)tmp)->ob_shash;
 	}
 	Py_DECREF(tmp);
 	return pnew;
@@ -3043,10 +3043,10 @@
 
 static PyObject *str_iter(PyObject *seq);
 
-PyTypeObject PyString_Type = {
+PyTypeObject PyBytes_Type = {
 	PyVarObject_HEAD_INIT(&PyType_Type, 0)
 	"bytes",
-	sizeof(PyStringObject),
+	sizeof(PyBytesObject),
 	sizeof(char),
  	string_dealloc, 			/* tp_dealloc */
 	0,			 		/* tp_print */
@@ -3064,7 +3064,7 @@
 	0,					/* tp_setattro */
 	&string_as_buffer,			/* tp_as_buffer */
 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
-		Py_TPFLAGS_STRING_SUBCLASS,	/* tp_flags */
+		Py_TPFLAGS_BYTES_SUBCLASS,	/* tp_flags */
 	string_doc,				/* tp_doc */
 	0,					/* tp_traverse */
 	0,					/* tp_clear */
@@ -3087,7 +3087,7 @@
 };
 
 void
-PyString_Concat(register PyObject **pv, register PyObject *w)
+PyBytes_Concat(register PyObject **pv, register PyObject *w)
 {
 	register PyObject *v;
 	assert(pv != NULL);
@@ -3104,9 +3104,9 @@
 }
 
 void
-PyString_ConcatAndDel(register PyObject **pv, register PyObject *w)
+PyBytes_ConcatAndDel(register PyObject **pv, register PyObject *w)
 {
-	PyString_Concat(pv, w);
+	PyBytes_Concat(pv, w);
 	Py_XDECREF(w);
 }
 
@@ -3126,12 +3126,12 @@
 */
 
 int
-_PyString_Resize(PyObject **pv, Py_ssize_t newsize)
+_PyBytes_Resize(PyObject **pv, Py_ssize_t newsize)
 {
 	register PyObject *v;
-	register PyStringObject *sv;
+	register PyBytesObject *sv;
 	v = *pv;
-	if (!PyString_Check(v) || Py_REFCNT(v) != 1 || newsize < 0) {
+	if (!PyBytes_Check(v) || Py_REFCNT(v) != 1 || newsize < 0) {
 		*pv = 0;
 		Py_DECREF(v);
 		PyErr_BadInternalCall();
@@ -3141,21 +3141,21 @@
 	_Py_DEC_REFTOTAL;
 	_Py_ForgetReference(v);
 	*pv = (PyObject *)
-		PyObject_REALLOC((char *)v, sizeof(PyStringObject) + newsize);
+		PyObject_REALLOC((char *)v, sizeof(PyBytesObject) + newsize);
 	if (*pv == NULL) {
 		PyObject_Del(v);
 		PyErr_NoMemory();
 		return -1;
 	}
 	_Py_NewReference(*pv);
-	sv = (PyStringObject *) *pv;
+	sv = (PyBytesObject *) *pv;
 	Py_SIZE(sv) = newsize;
 	sv->ob_sval[newsize] = '\0';
 	sv->ob_shash = -1;	/* invalidate cached hash value */
 	return 0;
 }
 
-/* _PyString_FormatLong emulates the format codes d, u, o, x and X, and
+/* _PyBytes_FormatLong emulates the format codes d, u, o, x and X, and
  * the F_ALT flag, for Python's long (unbounded) ints.  It's not used for
  * Python's regular ints.
  * Return value:  a new PyString*, or NULL if error.
@@ -3177,7 +3177,7 @@
  * produce a '-' sign, but can for Python's unbounded ints.
  */
 PyObject*
-_PyString_FormatLong(PyObject *val, int flags, int prec, int type,
+_PyBytes_FormatLong(PyObject *val, int flags, int prec, int type,
 		     char **pbuf, int *plen)
 {
 	PyObject *result = NULL;
@@ -3234,7 +3234,7 @@
 	llen = PyUnicode_GetSize(result);
 	if (llen > INT_MAX) {
 		PyErr_SetString(PyExc_ValueError,
-				"string too large in _PyString_FormatLong");
+				"string too large in _PyBytes_FormatLong");
 		return NULL;
 	}
 	len = (int)llen;
@@ -3264,14 +3264,14 @@
 
 	/* Fill with leading zeroes to meet minimum width. */
 	if (prec > numdigits) {
-		PyObject *r1 = PyString_FromStringAndSize(NULL,
+		PyObject *r1 = PyBytes_FromStringAndSize(NULL,
 					numnondigits + prec);
 		char *b1;
 		if (!r1) {
 			Py_DECREF(result);
 			return NULL;
 		}
-		b1 = PyString_AS_STRING(r1);
+		b1 = PyBytes_AS_STRING(r1);
 		for (i = 0; i < numnondigits; ++i)
 			*b1++ = *buf++;
 		for (i = 0; i < prec - numdigits; i++)
@@ -3281,7 +3281,7 @@
 		*b1 = '\0';
 		Py_DECREF(result);
 		result = r1;
-		buf = PyString_AS_STRING(result);
+		buf = PyBytes_AS_STRING(result);
 		len = numnondigits + prec;
 	}
 
@@ -3299,7 +3299,7 @@
 }
 
 void
-PyString_Fini(void)
+PyBytes_Fini(void)
 {
 	int i;
 	for (i = 0; i < UCHAR_MAX + 1; i++) {
@@ -3315,7 +3315,7 @@
 typedef struct {
 	PyObject_HEAD
 	Py_ssize_t it_index;
-	PyStringObject *it_seq; /* Set to NULL when iterator is exhausted */
+	PyBytesObject *it_seq; /* Set to NULL when iterator is exhausted */
 } striterobject;
 
 static void
@@ -3336,16 +3336,16 @@
 static PyObject *
 striter_next(striterobject *it)
 {
-	PyStringObject *seq;
+	PyBytesObject *seq;
 	PyObject *item;
 
 	assert(it != NULL);
 	seq = it->it_seq;
 	if (seq == NULL)
 		return NULL;
-	assert(PyString_Check(seq));
+	assert(PyBytes_Check(seq));
 
-	if (it->it_index < PyString_GET_SIZE(seq)) {
+	if (it->it_index < PyBytes_GET_SIZE(seq)) {
 		item = PyLong_FromLong(
 			(unsigned char)seq->ob_sval[it->it_index]);
 		if (item != NULL)
@@ -3363,7 +3363,7 @@
 {
 	Py_ssize_t len = 0;
 	if (it->it_seq)
-		len = PyString_GET_SIZE(it->it_seq) - it->it_index;
+		len = PyBytes_GET_SIZE(it->it_seq) - it->it_index;
 	return PyLong_FromSsize_t(len);
 }
 
@@ -3376,7 +3376,7 @@
  	{NULL,		NULL}		/* sentinel */
 };
 
-PyTypeObject PyStringIter_Type = {
+PyTypeObject PyBytesIter_Type = {
 	PyVarObject_HEAD_INIT(&PyType_Type, 0)
 	"bytes_iterator",			/* tp_name */
 	sizeof(striterobject),			/* tp_basicsize */
@@ -3414,16 +3414,16 @@
 {
 	striterobject *it;
 
-	if (!PyString_Check(seq)) {
+	if (!PyBytes_Check(seq)) {
 		PyErr_BadInternalCall();
 		return NULL;
 	}
-	it = PyObject_GC_New(striterobject, &PyStringIter_Type);
+	it = PyObject_GC_New(striterobject, &PyBytesIter_Type);
 	if (it == NULL)
 		return NULL;
 	it->it_index = 0;
 	Py_INCREF(seq);
-	it->it_seq = (PyStringObject *)seq;
+	it->it_seq = (PyBytesObject *)seq;
 	_PyObject_GC_TRACK(it);
 	return (PyObject *)it;
 }

Modified: python/branches/py3k/Objects/typeobject.c
==============================================================================
--- python/branches/py3k/Objects/typeobject.c	(original)
+++ python/branches/py3k/Objects/typeobject.c	Mon May 26 15:28:38 2008
@@ -3462,8 +3462,8 @@
 		type->tp_flags |= Py_TPFLAGS_TYPE_SUBCLASS;
 	else if (PyType_IsSubtype(base, &PyLong_Type))
 		type->tp_flags |= Py_TPFLAGS_LONG_SUBCLASS;
-	else if (PyType_IsSubtype(base, &PyString_Type))
-		type->tp_flags |= Py_TPFLAGS_STRING_SUBCLASS;
+	else if (PyType_IsSubtype(base, &PyBytes_Type))
+		type->tp_flags |= Py_TPFLAGS_BYTES_SUBCLASS;
 	else if (PyType_IsSubtype(base, &PyUnicode_Type))
 		type->tp_flags |= Py_TPFLAGS_UNICODE_SUBCLASS;
 	else if (PyType_IsSubtype(base, &PyTuple_Type))

Modified: python/branches/py3k/Objects/unicodeobject.c
==============================================================================
--- python/branches/py3k/Objects/unicodeobject.c	(original)
+++ python/branches/py3k/Objects/unicodeobject.c	Mon May 26 15:28:38 2008
@@ -1100,9 +1100,9 @@
 	}
 
     /* Coerce object */
-    if (PyString_Check(obj)) {
-	    s = PyString_AS_STRING(obj);
-	    len = PyString_GET_SIZE(obj);
+    if (PyBytes_Check(obj)) {
+	    s = PyBytes_AS_STRING(obj);
+	    len = PyBytes_GET_SIZE(obj);
 	    }
     else if (PyObject_AsCharBuffer(obj, &s, &len)) {
 	/* Overwrite the error message with something more useful in
@@ -1298,7 +1298,7 @@
     v = PyCodec_Encode(unicode, encoding, errors);
     if (v == NULL)
         goto onError;
-    assert(PyString_Check(v));
+    assert(PyBytes_Check(v));
     return v;
 
  onError:
@@ -1367,8 +1367,8 @@
     if (bytes == NULL)
         return NULL;
     if (psize != NULL)
-        *psize = PyString_GET_SIZE(bytes);
-    return PyString_AS_STRING(bytes);
+        *psize = PyBytes_GET_SIZE(bytes);
+    return PyBytes_AS_STRING(bytes);
 }
 
 char*
@@ -1480,11 +1480,11 @@
     inputobj = PyUnicodeDecodeError_GetObject(*exceptionObject);
     if (!inputobj)
         goto onError;
-    if (!PyString_Check(inputobj)) {
+    if (!PyBytes_Check(inputobj)) {
 	PyErr_Format(PyExc_TypeError, "exception attribute object must be bytes");
     }
-    *input = PyString_AS_STRING(inputobj);
-    insize = PyString_GET_SIZE(inputobj);
+    *input = PyBytes_AS_STRING(inputobj);
+    insize = PyBytes_GET_SIZE(inputobj);
     *inend = *input + insize;
     /* we can DECREF safely, as the exception has another reference,
        so the object won't go away. */
@@ -1762,7 +1762,7 @@
     char * start;
 
     if (size == 0)
-       return PyString_FromStringAndSize(NULL, 0);
+       return PyBytes_FromStringAndSize(NULL, 0);
 
     v = PyByteArray_FromStringAndSize(NULL, cbAllocated);
     if (v == NULL)
@@ -1834,7 +1834,7 @@
         *out++ = '-';
     }
 
-    result = PyString_FromStringAndSize(PyByteArray_AS_STRING(v), out - start);
+    result = PyBytes_FromStringAndSize(PyByteArray_AS_STRING(v), out - start);
     Py_DECREF(v);
     return result;
 }
@@ -2100,10 +2100,10 @@
         nallocated = size * 4;
         if (nallocated / 4 != size)  /* overflow! */
             return PyErr_NoMemory();
-        result = PyString_FromStringAndSize(NULL, nallocated);
+        result = PyBytes_FromStringAndSize(NULL, nallocated);
         if (result == NULL)
             return NULL;
-        p = PyString_AS_STRING(result);
+        p = PyBytes_AS_STRING(result);
     }
 
     for (i = 0; i < size;) {
@@ -2151,13 +2151,13 @@
         /* This was stack allocated. */
         nneeded = p - stackbuf;
         assert(nneeded <= nallocated);
-        result = PyString_FromStringAndSize(stackbuf, nneeded);
+        result = PyBytes_FromStringAndSize(stackbuf, nneeded);
     }
     else {
         /* Cut back to size actually needed. */
-        nneeded = p - PyString_AS_STRING(result);
+        nneeded = p - PyBytes_AS_STRING(result);
         assert(nneeded <= nallocated);
-        _PyString_Resize(&result, nneeded);
+        _PyBytes_Resize(&result, nneeded);
     }
     return result;
 
@@ -2427,7 +2427,7 @@
     }
 
   done:
-    result = PyString_FromStringAndSize(PyByteArray_AS_STRING(v), Py_SIZE(v));
+    result = PyBytes_FromStringAndSize(PyByteArray_AS_STRING(v), Py_SIZE(v));
     Py_DECREF(v);
     return result;
 #undef STORECHAR
@@ -2691,7 +2691,7 @@
     }
 
   done:
-    result = PyString_FromStringAndSize(PyByteArray_AS_STRING(v), Py_SIZE(v));
+    result = PyBytes_FromStringAndSize(PyByteArray_AS_STRING(v), Py_SIZE(v));
     Py_DECREF(v);
     return result;
 #undef STORECHAR
@@ -3106,7 +3106,7 @@
             *p++ = (char) ch;
     }
 
-    result = PyString_FromStringAndSize(PyByteArray_AS_STRING(repr),
+    result = PyBytes_FromStringAndSize(PyByteArray_AS_STRING(repr),
                                         p - PyByteArray_AS_STRING(repr));
     Py_DECREF(repr);
     return result;
@@ -3124,7 +3124,7 @@
 
     if (!s)
         return NULL;
-    result = PyString_FromStringAndSize(PyByteArray_AS_STRING(s),
+    result = PyBytes_FromStringAndSize(PyByteArray_AS_STRING(s),
                                         PyByteArray_GET_SIZE(s));
     Py_DECREF(s);
     return result;
@@ -3327,7 +3327,7 @@
     size = p - q;
 
   done:
-    result = PyString_FromStringAndSize(PyByteArray_AS_STRING(repr), size);
+    result = PyBytes_FromStringAndSize(PyByteArray_AS_STRING(repr), size);
     Py_DECREF(repr);
     return result;
 }
@@ -3344,7 +3344,7 @@
 
     if (!s)
         return NULL;
-    result = PyString_FromStringAndSize(PyByteArray_AS_STRING(s),
+    result = PyBytes_FromStringAndSize(PyByteArray_AS_STRING(s),
                                         PyByteArray_GET_SIZE(s));
     Py_DECREF(s);
     return result;
@@ -3577,7 +3577,7 @@
     /* allocate enough for a simple encoding without
        replacements, if we need more, we'll resize */
     if (size == 0)
-        return PyString_FromStringAndSize(NULL, 0);
+        return PyBytes_FromStringAndSize(NULL, 0);
     res = PyByteArray_FromStringAndSize(NULL, size);
     if (res == NULL)
         return NULL;
@@ -3708,7 +3708,7 @@
 	    }
 	}
     }
-    result = PyString_FromStringAndSize(PyByteArray_AS_STRING(res),
+    result = PyBytes_FromStringAndSize(PyByteArray_AS_STRING(res),
                                         str - PyByteArray_AS_STRING(res));
   onError:
     Py_DECREF(res);
@@ -3960,20 +3960,20 @@
 
     if (*repr == NULL) {
 	/* Create string object */
-	*repr = PyString_FromStringAndSize(NULL, mbcssize);
+	*repr = PyBytes_FromStringAndSize(NULL, mbcssize);
 	if (*repr == NULL)
 	    return -1;
     }
     else {
 	/* Extend string object */
-	n = PyString_Size(*repr);
-	if (_PyString_Resize(repr, n + mbcssize) < 0)
+	n = PyBytes_Size(*repr);
+	if (_PyBytes_Resize(repr, n + mbcssize) < 0)
 	    return -1;
     }
 
     /* Do the conversion */
     if (size > 0) {
-	char *s = PyString_AS_STRING(*repr) + n;
+	char *s = PyBytes_AS_STRING(*repr) + n;
 	if (0 == WideCharToMultiByte(CP_ACP, 0, p, size, s, mbcssize, NULL, NULL)) {
 	    PyErr_SetFromWindowsErrWithFilename(0, NULL);
 	    return -1;
@@ -4440,7 +4440,7 @@
 	}
 	return x;
     }
-    else if (PyString_Check(x))
+    else if (PyBytes_Check(x))
 	return x;
     else {
 	/* wrong return value */
@@ -4455,11 +4455,11 @@
 static int
 charmapencode_resize(PyObject **outobj, Py_ssize_t *outpos, Py_ssize_t requiredsize)
 {
-	Py_ssize_t outsize = PyString_GET_SIZE(*outobj);
+	Py_ssize_t outsize = PyBytes_GET_SIZE(*outobj);
 	/* exponentially overallocate to minimize reallocations */
 	if (requiredsize < 2*outsize)
 	    requiredsize = 2*outsize;
-	if (_PyString_Resize(outobj, requiredsize))
+	if (_PyBytes_Resize(outobj, requiredsize))
 	    return -1;
 	return 0;
 }
@@ -4479,7 +4479,7 @@
 {
     PyObject *rep;
     char *outstart;
-    Py_ssize_t outsize = PyString_GET_SIZE(*outobj);
+    Py_ssize_t outsize = PyBytes_GET_SIZE(*outobj);
 
     if (Py_TYPE(mapping) == &EncodingMapType) {
         int res = encoding_map_lookup(c, mapping);
@@ -4489,7 +4489,7 @@
 	if (outsize<requiredsize)
 	    if (charmapencode_resize(outobj, outpos, requiredsize))
 		return enc_EXCEPTION;
-        outstart = PyString_AS_STRING(*outobj);
+        outstart = PyBytes_AS_STRING(*outobj);
 	outstart[(*outpos)++] = (char)res;
 	return enc_SUCCESS;
     }
@@ -4508,19 +4508,19 @@
 		    Py_DECREF(rep);
 		    return enc_EXCEPTION;
 		}
-            outstart = PyString_AS_STRING(*outobj);
+            outstart = PyBytes_AS_STRING(*outobj);
 	    outstart[(*outpos)++] = (char)PyLong_AS_LONG(rep);
 	}
 	else {
-	    const char *repchars = PyString_AS_STRING(rep);
-	    Py_ssize_t repsize = PyString_GET_SIZE(rep);
+	    const char *repchars = PyBytes_AS_STRING(rep);
+	    Py_ssize_t repsize = PyBytes_GET_SIZE(rep);
 	    Py_ssize_t requiredsize = *outpos+repsize;
 	    if (outsize<requiredsize)
 		if (charmapencode_resize(outobj, outpos, requiredsize)) {
 		    Py_DECREF(rep);
 		    return enc_EXCEPTION;
 		}
-            outstart = PyString_AS_STRING(*outobj);
+            outstart = PyBytes_AS_STRING(*outobj);
 	    memcpy(outstart + *outpos, repchars, repsize);
 	    *outpos += repsize;
 	}
@@ -4671,7 +4671,7 @@
 
     /* allocate enough for a simple encoding without
        replacements, if we need more, we'll resize */
-    res = PyString_FromStringAndSize(NULL, size);
+    res = PyBytes_FromStringAndSize(NULL, size);
     if (res == NULL)
         goto onError;
     if (size == 0)
@@ -4696,8 +4696,8 @@
     }
 
     /* Resize if we allocated to much */
-    if (respos<PyString_GET_SIZE(res))
-	_PyString_Resize(&res, respos);
+    if (respos<PyBytes_GET_SIZE(res))
+	_PyBytes_Resize(&res, respos);
 
     Py_XDECREF(exc);
     Py_XDECREF(errorHandler);
@@ -6622,7 +6622,7 @@
     v = PyUnicode_AsEncodedObject((PyObject *)self, encoding, errors);
     if (v == NULL)
         goto onError;
-    if (!PyString_Check(v)) {
+    if (!PyBytes_Check(v)) {
         PyErr_Format(PyExc_TypeError,
                      "encoder did not return a bytes object "
                      "(type=%.400s)",
@@ -8475,7 +8475,7 @@
 	PyObject *str; /* temporary string object. */
 	PyObject *result;
 
-	str = _PyString_FormatLong(val, flags, prec, type, &buf, &len);
+	str = _PyBytes_FormatLong(val, flags, prec, type, &buf, &len);
 	if (!str)
 		return NULL;
 	result = PyUnicode_FromStringAndSize(buf, len);

Modified: python/branches/py3k/PC/_msi.c
==============================================================================
--- python/branches/py3k/PC/_msi.c	(original)
+++ python/branches/py3k/PC/_msi.c	Mon May 26 15:28:38 2008
@@ -35,7 +35,7 @@
 	return NULL;
     }
 
-    oresult = PyString_FromString(cresult);
+    oresult = PyBytes_FromString(cresult);
     RpcStringFree(&cresult);
     return oresult;
 
@@ -136,14 +136,14 @@
 	PyObject *result = PyObject_CallMethod(pv, "getnextcabinet", "i", pccab->iCab);
 	if (result == NULL)
 	    return -1;
-	if (!PyString_Check(result)) {
+	if (!PyBytes_Check(result)) {
 	    PyErr_Format(PyExc_TypeError, 
 		"Incorrect return type %s from getnextcabinet",
 		result->ob_type->tp_name);
 	    Py_DECREF(result);
 	    return FALSE;
 	}
-	strncpy(pccab->szCab, PyString_AsString(result), sizeof(pccab->szCab));
+	strncpy(pccab->szCab, PyBytes_AsString(result), sizeof(pccab->szCab));
 	return TRUE;
     }
     return FALSE;
@@ -507,7 +507,7 @@
 	    PyErr_SetString(PyExc_NotImplementedError, "FILETIME result");
 	    return NULL;
 	case VT_LPSTR:
-	    result = PyString_FromStringAndSize(sval, ssize);
+	    result = PyBytes_FromStringAndSize(sval, ssize);
 	    if (sval != sbuf)
 		free(sval);
 	    return result;
@@ -539,9 +539,9 @@
     if (!PyArg_ParseTuple(args, "iO:SetProperty", &field, &data))
 	return NULL;
 
-    if (PyString_Check(data)) {
+    if (PyBytes_Check(data)) {
 	status = MsiSummaryInfoSetProperty(si->h, field, VT_LPSTR,
-	    0, NULL, PyString_AsString(data));
+	    0, NULL, PyBytes_AsString(data));
     } else if (PyLong_CheckExact(data)) {
 	long value = PyLong_AsLong(data);
 	if (value == -1 && PyErr_Occurred()) {

Modified: python/branches/py3k/PC/msvcrtmodule.c
==============================================================================
--- python/branches/py3k/PC/msvcrtmodule.c	(original)
+++ python/branches/py3k/PC/msvcrtmodule.c	Mon May 26 15:28:38 2008
@@ -142,7 +142,7 @@
 	ch = _getch();
 	Py_END_ALLOW_THREADS
 	s[0] = ch;
-	return PyString_FromStringAndSize(s, 1);
+	return PyBytes_FromStringAndSize(s, 1);
 }
 
 #if _MSC_VER >= 1300
@@ -176,7 +176,7 @@
 	ch = _getche();
 	Py_END_ALLOW_THREADS
 	s[0] = ch;
-	return PyString_FromStringAndSize(s, 1);
+	return PyBytes_FromStringAndSize(s, 1);
 }
 
 #if _MSC_VER >= 1300

Modified: python/branches/py3k/Parser/asdl_c.py
==============================================================================
--- python/branches/py3k/Parser/asdl_c.py	(original)
+++ python/branches/py3k/Parser/asdl_c.py	Mon May 26 15:28:38 2008
@@ -374,7 +374,7 @@
         # there's really nothing more we can do if this fails ...
         self.emit("if (tmp == NULL) goto failed;", 1)
         error = "expected some sort of %s, but got %%.400s" % name
-        format = "PyErr_Format(PyExc_TypeError, \"%s\", PyString_AS_STRING(tmp));"
+        format = "PyErr_Format(PyExc_TypeError, \"%s\", PyBytes_AS_STRING(tmp));"
         self.emit(format % error, 1, reflow=False)
         self.emit("failed:", 0)
         self.emit("Py_XDECREF(tmp);", 1)
@@ -792,7 +792,7 @@
         PyObject *s = PyObject_Repr(obj);
         if (s == NULL) return 1;
         PyErr_Format(PyExc_ValueError, "invalid integer value: %.400s",
-                     PyString_AS_STRING(s));
+                     PyBytes_AS_STRING(s));
         Py_DECREF(s);
         return 1;
     }

Modified: python/branches/py3k/Parser/tokenizer.c
==============================================================================
--- python/branches/py3k/Parser/tokenizer.c	(original)
+++ python/branches/py3k/Parser/tokenizer.c	Mon May 26 15:28:38 2008
@@ -644,7 +644,7 @@
 		utf8 = translate_into_utf8(str, tok->enc);
 		if (utf8 == NULL)
 			return error_ret(tok);
-		str = PyString_AsString(utf8);
+		str = PyBytes_AsString(utf8);
 	}
 	for (s = str;; s++) {
 		if (*s == '\0') break;
@@ -675,7 +675,7 @@
 				"unknown encoding: %s", tok->enc);
 			return error_ret(tok);
 		}
-		str = PyString_AS_STRING(utf8);
+		str = PyBytes_AS_STRING(utf8);
 	}
 	assert(tok->decoding_buffer == NULL);
 	tok->decoding_buffer = utf8; /* CAUTION */
@@ -794,8 +794,8 @@
 					tok->done = E_DECODE;
 					return EOF;
 				}
-				buflen = PyString_GET_SIZE(u);
-				buf = PyString_AS_STRING(u);
+				buflen = PyBytes_GET_SIZE(u);
+				buf = PyBytes_AS_STRING(u);
 				if (!buf) {
 					Py_DECREF(u);
 					tok->done = E_DECODE;

Modified: python/branches/py3k/Python/Python-ast.c
==============================================================================
--- python/branches/py3k/Python/Python-ast.c	(original)
+++ python/branches/py3k/Python/Python-ast.c	Mon May 26 15:28:38 2008
@@ -609,7 +609,7 @@
         PyObject *s = PyObject_Repr(obj);
         if (s == NULL) return 1;
         PyErr_Format(PyExc_ValueError, "invalid integer value: %.400s",
-                     PyString_AS_STRING(s));
+                     PyBytes_AS_STRING(s));
         Py_DECREF(s);
         return 1;
     }
@@ -3485,7 +3485,7 @@
 
         tmp = PyObject_Repr(obj);
         if (tmp == NULL) goto failed;
-        PyErr_Format(PyExc_TypeError, "expected some sort of mod, but got %.400s", PyString_AS_STRING(tmp));
+        PyErr_Format(PyExc_TypeError, "expected some sort of mod, but got %.400s", PyBytes_AS_STRING(tmp));
 failed:
         Py_XDECREF(tmp);
         return 1;
@@ -4595,7 +4595,7 @@
 
         tmp = PyObject_Repr(obj);
         if (tmp == NULL) goto failed;
-        PyErr_Format(PyExc_TypeError, "expected some sort of stmt, but got %.400s", PyString_AS_STRING(tmp));
+        PyErr_Format(PyExc_TypeError, "expected some sort of stmt, but got %.400s", PyBytes_AS_STRING(tmp));
 failed:
         Py_XDECREF(tmp);
         return 1;
@@ -5616,7 +5616,7 @@
 
         tmp = PyObject_Repr(obj);
         if (tmp == NULL) goto failed;
-        PyErr_Format(PyExc_TypeError, "expected some sort of expr, but got %.400s", PyString_AS_STRING(tmp));
+        PyErr_Format(PyExc_TypeError, "expected some sort of expr, but got %.400s", PyBytes_AS_STRING(tmp));
 failed:
         Py_XDECREF(tmp);
         return 1;
@@ -5654,7 +5654,7 @@
 
         tmp = PyObject_Repr(obj);
         if (tmp == NULL) goto failed;
-        PyErr_Format(PyExc_TypeError, "expected some sort of expr_context, but got %.400s", PyString_AS_STRING(tmp));
+        PyErr_Format(PyExc_TypeError, "expected some sort of expr_context, but got %.400s", PyBytes_AS_STRING(tmp));
 failed:
         Py_XDECREF(tmp);
         return 1;
@@ -5766,7 +5766,7 @@
 
         tmp = PyObject_Repr(obj);
         if (tmp == NULL) goto failed;
-        PyErr_Format(PyExc_TypeError, "expected some sort of slice, but got %.400s", PyString_AS_STRING(tmp));
+        PyErr_Format(PyExc_TypeError, "expected some sort of slice, but got %.400s", PyBytes_AS_STRING(tmp));
 failed:
         Py_XDECREF(tmp);
         return 1;
@@ -5788,7 +5788,7 @@
 
         tmp = PyObject_Repr(obj);
         if (tmp == NULL) goto failed;
-        PyErr_Format(PyExc_TypeError, "expected some sort of boolop, but got %.400s", PyString_AS_STRING(tmp));
+        PyErr_Format(PyExc_TypeError, "expected some sort of boolop, but got %.400s", PyBytes_AS_STRING(tmp));
 failed:
         Py_XDECREF(tmp);
         return 1;
@@ -5850,7 +5850,7 @@
 
         tmp = PyObject_Repr(obj);
         if (tmp == NULL) goto failed;
-        PyErr_Format(PyExc_TypeError, "expected some sort of operator, but got %.400s", PyString_AS_STRING(tmp));
+        PyErr_Format(PyExc_TypeError, "expected some sort of operator, but got %.400s", PyBytes_AS_STRING(tmp));
 failed:
         Py_XDECREF(tmp);
         return 1;
@@ -5880,7 +5880,7 @@
 
         tmp = PyObject_Repr(obj);
         if (tmp == NULL) goto failed;
-        PyErr_Format(PyExc_TypeError, "expected some sort of unaryop, but got %.400s", PyString_AS_STRING(tmp));
+        PyErr_Format(PyExc_TypeError, "expected some sort of unaryop, but got %.400s", PyBytes_AS_STRING(tmp));
 failed:
         Py_XDECREF(tmp);
         return 1;
@@ -5934,7 +5934,7 @@
 
         tmp = PyObject_Repr(obj);
         if (tmp == NULL) goto failed;
-        PyErr_Format(PyExc_TypeError, "expected some sort of cmpop, but got %.400s", PyString_AS_STRING(tmp));
+        PyErr_Format(PyExc_TypeError, "expected some sort of cmpop, but got %.400s", PyBytes_AS_STRING(tmp));
 failed:
         Py_XDECREF(tmp);
         return 1;
@@ -6100,7 +6100,7 @@
 
         tmp = PyObject_Repr(obj);
         if (tmp == NULL) goto failed;
-        PyErr_Format(PyExc_TypeError, "expected some sort of excepthandler, but got %.400s", PyString_AS_STRING(tmp));
+        PyErr_Format(PyExc_TypeError, "expected some sort of excepthandler, but got %.400s", PyBytes_AS_STRING(tmp));
 failed:
         Py_XDECREF(tmp);
         return 1;

Modified: python/branches/py3k/Python/ast.c
==============================================================================
--- python/branches/py3k/Python/ast.c	(original)
+++ python/branches/py3k/Python/ast.c	Mon May 26 15:28:38 2008
@@ -2293,10 +2293,10 @@
                     /* length of string plus one for the dot */
                     len += strlen(STR(CHILD(n, i))) + 1;
                 len--; /* the last name doesn't have a dot */
-                str = PyString_FromStringAndSize(NULL, len);
+                str = PyBytes_FromStringAndSize(NULL, len);
                 if (!str)
                     return NULL;
-                s = PyString_AS_STRING(str);
+                s = PyBytes_AS_STRING(str);
                 if (!s)
                     return NULL;
                 for (i = 0; i < NCH(n); i += 2) {
@@ -2307,8 +2307,8 @@
                 }
                 --s;
                 *s = '\0';
-		uni = PyUnicode_DecodeUTF8(PyString_AS_STRING(str),
-					   PyString_GET_SIZE(str), 
+		uni = PyUnicode_DecodeUTF8(PyBytes_AS_STRING(str),
+					   PyBytes_GET_SIZE(str), 
 					   NULL);
 		Py_DECREF(str);
 		if (!uni)
@@ -3146,10 +3146,10 @@
         u = NULL;
     } else {
         /* "\XX" may become "\u005c\uHHLL" (12 bytes) */
-        u = PyString_FromStringAndSize((char *)NULL, len * 4);
+        u = PyBytes_FromStringAndSize((char *)NULL, len * 4);
         if (u == NULL)
             return NULL;
-        p = buf = PyString_AsString(u);
+        p = buf = PyBytes_AsString(u);
         end = s + len;
         while (s < end) {
             if (*s == '\\') {
@@ -3168,7 +3168,7 @@
                     Py_DECREF(u);
                     return NULL;
                 }
-                r = PyString_AS_STRING(w);
+                r = PyBytes_AS_STRING(w);
                 rn = Py_SIZE(w);
                 assert(rn % 2 == 0);
                 for (i = 0; i < rn; i += 2) {
@@ -3264,14 +3264,14 @@
             Py_DECREF(u);
             return v;
         } else if (*bytesmode) {
-            return PyString_FromStringAndSize(s, len);
+            return PyBytes_FromStringAndSize(s, len);
         } else if (strcmp(c->c_encoding, "utf-8") == 0) {
             return PyUnicode_FromStringAndSize(s, len);
 	} else {
             return PyUnicode_DecodeLatin1(s, len, NULL);
         }
     }
-    return PyString_DecodeEscape(s, len, NULL, 1,
+    return PyBytes_DecodeEscape(s, len, NULL, 1,
                                  need_encoding ? c->c_encoding : NULL);
 }
 
@@ -3298,8 +3298,8 @@
                 ast_error(n, "cannot mix bytes and nonbytes literals");
                 goto onError;
             }
-            if (PyString_Check(v) && PyString_Check(s)) {
-                PyString_ConcatAndDel(&v, s);
+            if (PyBytes_Check(v) && PyBytes_Check(s)) {
+                PyBytes_ConcatAndDel(&v, s);
                 if (v == NULL)
                     goto onError;
             }

Modified: python/branches/py3k/Python/bltinmodule.c
==============================================================================
--- python/branches/py3k/Python/bltinmodule.c	(original)
+++ python/branches/py3k/Python/bltinmodule.c	Mon May 26 15:28:38 2008
@@ -1350,10 +1350,10 @@
 	long ord;
 	Py_ssize_t size;
 
-	if (PyString_Check(obj)) {
-		size = PyString_GET_SIZE(obj);
+	if (PyBytes_Check(obj)) {
+		size = PyBytes_GET_SIZE(obj);
 		if (size == 1) {
-			ord = (long)((unsigned char)*PyString_AS_STRING(obj));
+			ord = (long)((unsigned char)*PyBytes_AS_STRING(obj));
 			return PyLong_FromLong(ord);
 		}
 	}
@@ -2267,7 +2267,7 @@
 	SETBUILTIN("bool",		&PyBool_Type);
 	SETBUILTIN("memoryview",        &PyMemoryView_Type);
 	SETBUILTIN("bytearray",		&PyByteArray_Type);
-	SETBUILTIN("bytes",		&PyString_Type);
+	SETBUILTIN("bytes",		&PyBytes_Type);
 	SETBUILTIN("classmethod",	&PyClassMethod_Type);
 #ifndef WITHOUT_COMPLEX
 	SETBUILTIN("complex",		&PyComplex_Type);

Modified: python/branches/py3k/Python/ceval.c
==============================================================================
--- python/branches/py3k/Python/ceval.c	(original)
+++ python/branches/py3k/Python/ceval.c	Mon May 26 15:28:38 2008
@@ -742,7 +742,7 @@
 	consts = co->co_consts;
 	fastlocals = f->f_localsplus;
 	freevars = f->f_localsplus + co->co_nlocals;
-	first_instr = (unsigned char*) PyString_AS_STRING(co->co_code);
+	first_instr = (unsigned char*) PyBytes_AS_STRING(co->co_code);
 	/* An explanation is in order for the next line.
 
 	   f->f_lasti now refers to the index of the last instruction

Modified: python/branches/py3k/Python/codecs.c
==============================================================================
--- python/branches/py3k/Python/codecs.c	(original)
+++ python/branches/py3k/Python/codecs.c	Mon May 26 15:28:38 2008
@@ -354,9 +354,9 @@
             v = NULL;
             goto onError;
         }
-        v = PyString_FromStringAndSize(PyByteArray_AS_STRING(v), Py_SIZE(v));
+        v = PyBytes_FromStringAndSize(PyByteArray_AS_STRING(v), Py_SIZE(v));
     }
-    else if (PyString_Check(v))
+    else if (PyBytes_Check(v))
         Py_INCREF(v);
     else {
         PyErr_SetString(PyExc_TypeError,

Modified: python/branches/py3k/Python/compile.c
==============================================================================
--- python/branches/py3k/Python/compile.c	(original)
+++ python/branches/py3k/Python/compile.c	Mon May 26 15:28:38 2008
@@ -1225,8 +1225,8 @@
 	    PyOS_snprintf(buf, sizeof(buf),
 			  "unknown scope for %.100s in %.100s(%s) in %s\n"
 			  "symbols: %s\nlocals: %s\nglobals: %s\n",
-			  PyString_AS_STRING(name), 
-			  PyString_AS_STRING(c->u->u_name), 
+			  PyBytes_AS_STRING(name), 
+			  PyBytes_AS_STRING(c->u->u_name), 
 			  PyObject_REPR(c->u->u_ste->ste_id),
 			  c->c_filename,
 			  PyObject_REPR(c->u->u_ste->ste_symbols),
@@ -1285,7 +1285,7 @@
 				"lookup %s in %s %d %d\n"
 				"freevars of %s: %s\n",
 				PyObject_REPR(name), 
-				PyString_AS_STRING(c->u->u_name), 
+				PyBytes_AS_STRING(c->u->u_name), 
 				reftype, arg,
 				PyUnicode_AsString(co->co_name),
 				PyObject_REPR(co->co_freevars));
@@ -3068,7 +3068,7 @@
 		return PyObject_IsTrue(e->v.Str.s);
 	case Name_kind:
 		/* optimize away names that can't be reassigned */
-		id = PyString_AS_STRING(
+		id = PyBytes_AS_STRING(
                     _PyUnicode_AsDefaultEncodedString(e->v.Name.id, NULL));
 		if (strcmp(id, "True") == 0) return 1;
 		if (strcmp(id, "False") == 0) return 0;
@@ -3682,10 +3682,10 @@
 {
 	memset(a, 0, sizeof(struct assembler));
 	a->a_lineno = firstlineno;
-	a->a_bytecode = PyString_FromStringAndSize(NULL, DEFAULT_CODE_SIZE);
+	a->a_bytecode = PyBytes_FromStringAndSize(NULL, DEFAULT_CODE_SIZE);
 	if (!a->a_bytecode)
 		return 0;
-	a->a_lnotab = PyString_FromStringAndSize(NULL, DEFAULT_LNOTAB_SIZE);
+	a->a_lnotab = PyBytes_FromStringAndSize(NULL, DEFAULT_LNOTAB_SIZE);
 	if (!a->a_lnotab)
 		return 0;
 	a->a_postorder = (basicblock **)PyObject_Malloc(
@@ -3794,17 +3794,17 @@
 	if (d_bytecode > 255) {
 		int j, nbytes, ncodes = d_bytecode / 255;
 		nbytes = a->a_lnotab_off + 2 * ncodes;
-		len = PyString_GET_SIZE(a->a_lnotab);
+		len = PyBytes_GET_SIZE(a->a_lnotab);
 		if (nbytes >= len) {
 			if (len * 2 < nbytes)
 				len = nbytes;
 			else
 				len *= 2;
-			if (_PyString_Resize(&a->a_lnotab, len) < 0)
+			if (_PyBytes_Resize(&a->a_lnotab, len) < 0)
 				return 0;
 		}
 		lnotab = (unsigned char *)
-			   PyString_AS_STRING(a->a_lnotab) + a->a_lnotab_off;
+			   PyBytes_AS_STRING(a->a_lnotab) + a->a_lnotab_off;
 		for (j = 0; j < ncodes; j++) {
 			*lnotab++ = 255;
 			*lnotab++ = 0;
@@ -3816,17 +3816,17 @@
 	if (d_lineno > 255) {
 		int j, nbytes, ncodes = d_lineno / 255;
 		nbytes = a->a_lnotab_off + 2 * ncodes;
-		len = PyString_GET_SIZE(a->a_lnotab);
+		len = PyBytes_GET_SIZE(a->a_lnotab);
 		if (nbytes >= len) {
 			if (len * 2 < nbytes)
 				len = nbytes;
 			else
 				len *= 2;
-			if (_PyString_Resize(&a->a_lnotab, len) < 0)
+			if (_PyBytes_Resize(&a->a_lnotab, len) < 0)
 				return 0;
 		}
 		lnotab = (unsigned char *)
-			   PyString_AS_STRING(a->a_lnotab) + a->a_lnotab_off;
+			   PyBytes_AS_STRING(a->a_lnotab) + a->a_lnotab_off;
 		*lnotab++ = d_bytecode;
 		*lnotab++ = 255;
 		d_bytecode = 0;
@@ -3838,13 +3838,13 @@
 		a->a_lnotab_off += ncodes * 2;
 	}
 
-	len = PyString_GET_SIZE(a->a_lnotab);
+	len = PyBytes_GET_SIZE(a->a_lnotab);
 	if (a->a_lnotab_off + 2 >= len) {
-		if (_PyString_Resize(&a->a_lnotab, len * 2) < 0)
+		if (_PyBytes_Resize(&a->a_lnotab, len * 2) < 0)
 			return 0;
 	}
 	lnotab = (unsigned char *)
-			PyString_AS_STRING(a->a_lnotab) + a->a_lnotab_off;
+			PyBytes_AS_STRING(a->a_lnotab) + a->a_lnotab_off;
 
 	a->a_lnotab_off += 2;
 	if (d_bytecode) {
@@ -3869,7 +3869,7 @@
 assemble_emit(struct assembler *a, struct instr *i)
 {
 	int size, arg = 0, ext = 0;
-	Py_ssize_t len = PyString_GET_SIZE(a->a_bytecode);
+	Py_ssize_t len = PyBytes_GET_SIZE(a->a_bytecode);
 	char *code;
 
 	size = instrsize(i);
@@ -3880,10 +3880,10 @@
 	if (i->i_lineno && !assemble_lnotab(a, i))
 		return 0;
 	if (a->a_offset + size >= len) {
-		if (_PyString_Resize(&a->a_bytecode, len * 2) < 0)
+		if (_PyBytes_Resize(&a->a_bytecode, len * 2) < 0)
 		    return 0;
 	}
-	code = PyString_AS_STRING(a->a_bytecode) + a->a_offset;
+	code = PyBytes_AS_STRING(a->a_bytecode) + a->a_offset;
 	a->a_offset += size;
 	if (size == 6) {
 		assert(i->i_hasarg);
@@ -4177,9 +4177,9 @@
 				goto error;
 	}
 
-	if (_PyString_Resize(&a.a_lnotab, a.a_lnotab_off) < 0)
+	if (_PyBytes_Resize(&a.a_lnotab, a.a_lnotab_off) < 0)
 		goto error;
-	if (_PyString_Resize(&a.a_bytecode, a.a_offset) < 0)
+	if (_PyBytes_Resize(&a.a_bytecode, a.a_offset) < 0)
 		goto error;
 
 	co = makecode(c, &a);

Modified: python/branches/py3k/Python/getargs.c
==============================================================================
--- python/branches/py3k/Python/getargs.c	(original)
+++ python/branches/py3k/Python/getargs.c	Mon May 26 15:28:38 2008
@@ -418,7 +418,7 @@
 			n++;
 	}
 
-	if (!PySequence_Check(arg) || PyString_Check(arg)) {
+	if (!PySequence_Check(arg) || PyBytes_Check(arg)) {
 		levels[0] = 0;
 		PyOS_snprintf(msgbuf, bufsize,
 			      toplevel ? "expected %d arguments, not %.50s" :
@@ -762,8 +762,8 @@
 
 	case 'c': {/* char */
 		char *p = va_arg(*p_va, char *);
-		if (PyString_Check(arg) && PyString_Size(arg) == 1)
-			*p = PyString_AS_STRING(arg)[0];
+		if (PyBytes_Check(arg) && PyBytes_Size(arg) == 1)
+			*p = PyBytes_AS_STRING(arg)[0];
 		else if (PyUnicode_Check(arg) &&
 			 PyUnicode_GET_SIZE(arg) == 1 &&
 			 PyUnicode_AS_UNICODE(arg)[0] < 256)
@@ -775,8 +775,8 @@
 
 	case 'C': {/* unicode char */
 		int *p = va_arg(*p_va, int *);
-		if (PyString_Check(arg) && PyString_Size(arg) == 1)
-			*p = PyString_AS_STRING(arg)[0];
+		if (PyBytes_Check(arg) && PyBytes_Size(arg) == 1)
+			*p = PyBytes_AS_STRING(arg)[0];
 		else if (PyUnicode_Check(arg) &&
 			 PyUnicode_GET_SIZE(arg) == 1)
 			*p = PyUnicode_AS_UNICODE(arg)[0];
@@ -798,8 +798,8 @@
 				if (uarg == NULL)
 					return converterr(CONV_UNICODE,
 							  arg, msgbuf, bufsize);
-				*p = PyString_AS_STRING(uarg);
-				STORE_SIZE(PyString_GET_SIZE(uarg));
+				*p = PyBytes_AS_STRING(uarg);
+				STORE_SIZE(PyBytes_GET_SIZE(uarg));
 			}
 			else { /* any buffer-like object */
 				/* XXX Really? */
@@ -818,11 +818,11 @@
 				if (uarg == NULL)
 					return converterr(CONV_UNICODE,
 							  arg, msgbuf, bufsize);
-				*p = PyString_AS_STRING(uarg);
+				*p = PyBytes_AS_STRING(uarg);
 			}
 			else
 				return converterr("string", arg, msgbuf, bufsize);
-			if ((Py_ssize_t) strlen(*p) != PyString_GET_SIZE(uarg))
+			if ((Py_ssize_t) strlen(*p) != PyBytes_GET_SIZE(uarg))
 				return converterr("string without null bytes",
 						  arg, msgbuf, bufsize);
 		}
@@ -857,8 +857,8 @@
 				if (uarg == NULL)
 					return converterr(CONV_UNICODE,
 							  arg, msgbuf, bufsize);
-				*p = PyString_AS_STRING(uarg);
-				STORE_SIZE(PyString_GET_SIZE(uarg));
+				*p = PyBytes_AS_STRING(uarg);
+				STORE_SIZE(PyBytes_GET_SIZE(uarg));
 			}
 			else { /* any buffer-like object */
 				/* XXX Really? */
@@ -875,17 +875,17 @@
 
 			if (arg == Py_None)
 				*p = 0;
-			else if (PyString_Check(arg)) {
+			else if (PyBytes_Check(arg)) {
 				/* Enable null byte check below */
 				uarg = arg;
-				*p = PyString_AS_STRING(arg);
+				*p = PyBytes_AS_STRING(arg);
 			}
 			else if (PyUnicode_Check(arg)) {
 				uarg = UNICODE_DEFAULT_ENCODING(arg);
 				if (uarg == NULL)
 					return converterr(CONV_UNICODE,
 							  arg, msgbuf, bufsize);
-				*p = PyString_AS_STRING(uarg);
+				*p = PyBytes_AS_STRING(uarg);
 			}
 			else
 				return converterr("string or None",
@@ -897,12 +897,12 @@
 					STORE_SIZE(0);
 				}
 				else {
-					STORE_SIZE(PyString_Size(arg));
+					STORE_SIZE(PyBytes_Size(arg));
 				}
 				format++;
 			}
 			else if (*p != NULL && uarg != NULL &&
-				(Py_ssize_t) strlen(*p) != PyString_GET_SIZE(uarg))
+				(Py_ssize_t) strlen(*p) != PyBytes_GET_SIZE(uarg))
 				return converterr(
 					"string without null bytes or None",
 					arg, msgbuf, bufsize);
@@ -971,7 +971,7 @@
 
 		/* Encode object */
 		if (!recode_strings &&
-                    (PyString_Check(arg) || PyByteArray_Check(arg))) {
+                    (PyBytes_Check(arg) || PyByteArray_Check(arg))) {
 			s = arg;
 			Py_INCREF(s);
                         if (PyObject_AsCharBuffer(s, &ptr, &size) < 0)
@@ -996,14 +996,14 @@
 			if (s == NULL)
 				return converterr("(encoding failed)",
 						  arg, msgbuf, bufsize);
-			if (!PyString_Check(s)) {
+			if (!PyBytes_Check(s)) {
 				Py_DECREF(s);
 				return converterr(
 					"(encoder failed to return bytes)",
 					arg, msgbuf, bufsize);
 			}
-			size = PyString_GET_SIZE(s);
-			ptr = PyString_AS_STRING(s);
+			size = PyBytes_GET_SIZE(s);
+			ptr = PyBytes_AS_STRING(s);
 			if (ptr == NULL)
 				ptr = "";
 		}
@@ -1114,9 +1114,9 @@
 		break;
 	}
 
-	case 'S': { /* PyString object */
+	case 'S': { /* PyBytes object */
 		PyObject **p = va_arg(*p_va, PyObject **);
-		if (PyString_Check(arg))
+		if (PyBytes_Check(arg))
 			*p = arg;
 		else
 			return converterr("bytes", arg, msgbuf, bufsize);

Modified: python/branches/py3k/Python/import.c
==============================================================================
--- python/branches/py3k/Python/import.c	(original)
+++ python/branches/py3k/Python/import.c	Mon May 26 15:28:38 2008
@@ -1322,10 +1322,10 @@
 			if (v == NULL)
 				return NULL;
 		}
-		if (!PyString_Check(v))
+		if (!PyBytes_Check(v))
 			continue;
-		base = PyString_AS_STRING(v);
-		size = PyString_GET_SIZE(v);
+		base = PyBytes_AS_STRING(v);
+		size = PyBytes_GET_SIZE(v);
 		len = size;
 		if (len + 2 + namelen + MAXSUFFIXSIZE >= buflen) {
 			continue; /* Too long */
@@ -2385,7 +2385,7 @@
 				PyErr_SetString(PyExc_ValueError, "Cannot encode path item");
 				return 0;
 			}
-			subname = PyString_AS_STRING(item8);
+			subname = PyBytes_AS_STRING(item8);
 			if (buflen + strlen(subname) >= MAXPATHLEN) {
 				PyErr_SetString(PyExc_ValueError,
 						"Module name too long");
@@ -2691,7 +2691,7 @@
 	buf[2] = (char) ((pyc_magic >> 16) & 0xff);
 	buf[3] = (char) ((pyc_magic >> 24) & 0xff);
 
-	return PyString_FromStringAndSize(buf, 4);
+	return PyBytes_FromStringAndSize(buf, 4);
 }
 
 static PyObject *

Modified: python/branches/py3k/Python/marshal.c
==============================================================================
--- python/branches/py3k/Python/marshal.c	(original)
+++ python/branches/py3k/Python/marshal.c	Mon May 26 15:28:38 2008
@@ -67,18 +67,18 @@
 	Py_ssize_t size, newsize;
 	if (p->str == NULL)
 		return; /* An error already occurred */
-	size = PyString_Size(p->str);
+	size = PyBytes_Size(p->str);
 	newsize = size + size + 1024;
 	if (newsize > 32*1024*1024) {
 		newsize = size + 1024*1024;
 	}
-	if (_PyString_Resize(&p->str, newsize) != 0) {
+	if (_PyBytes_Resize(&p->str, newsize) != 0) {
 		p->ptr = p->end = NULL;
 	}
 	else {
-		p->ptr = PyString_AS_STRING((PyStringObject *)p->str) + size;
+		p->ptr = PyBytes_AS_STRING((PyBytesObject *)p->str) + size;
 		p->end =
-			PyString_AS_STRING((PyStringObject *)p->str) + newsize;
+			PyBytes_AS_STRING((PyBytesObject *)p->str) + newsize;
 		*p->ptr++ = Py_SAFE_DOWNCAST(c, int, char);
 	}
 }
@@ -231,9 +231,9 @@
 		}
 	}
 #endif
-	else if (PyString_CheckExact(v)) {
+	else if (PyBytes_CheckExact(v)) {
 		w_byte(TYPE_STRING, p);
-		n = PyString_GET_SIZE(v);
+		n = PyBytes_GET_SIZE(v);
 		if (n > INT_MAX) {
 			/* huge strings are not supported */
 			p->depth--;
@@ -241,7 +241,7 @@
 			return;
 		}
 		w_long((long)n, p);
-		w_string(PyString_AS_STRING(v), (int)n, p);
+		w_string(PyBytes_AS_STRING(v), (int)n, p);
 	}
 	else if (PyUnicode_CheckExact(v)) {
 	        PyObject *utf8;
@@ -252,14 +252,14 @@
 			return;
 		}
 		w_byte(TYPE_UNICODE, p);
-		n = PyString_GET_SIZE(utf8);
+		n = PyBytes_GET_SIZE(utf8);
 		if (n > INT_MAX) {
 			p->depth--;
 			p->error = 1;
 			return;
 		}
 		w_long((long)n, p);
-		w_string(PyString_AS_STRING(utf8), (int)n, p);
+		w_string(PyBytes_AS_STRING(utf8), (int)n, p);
 		Py_DECREF(utf8);
 	}
 	else if (PyTuple_CheckExact(v)) {
@@ -686,12 +686,12 @@
 			retval = NULL;
 			break;
 		}
-		v = PyString_FromStringAndSize((char *)NULL, n);
+		v = PyBytes_FromStringAndSize((char *)NULL, n);
 		if (v == NULL) {
 			retval = NULL;
 			break;
 		}
-		if (r_string(PyString_AS_STRING(v), (int)n, p) != n) {
+		if (r_string(PyBytes_AS_STRING(v), (int)n, p) != n) {
 			Py_DECREF(v);
 			PyErr_SetString(PyExc_EOFError,
 					"EOF read where object expected");
@@ -1064,11 +1064,11 @@
 	PyObject *res = NULL;
 
 	wf.fp = NULL;
-	wf.str = PyString_FromStringAndSize((char *)NULL, 50);
+	wf.str = PyBytes_FromStringAndSize((char *)NULL, 50);
 	if (wf.str == NULL)
 		return NULL;
-	wf.ptr = PyString_AS_STRING((PyStringObject *)wf.str);
-	wf.end = wf.ptr + PyString_Size(wf.str);
+	wf.ptr = PyBytes_AS_STRING((PyBytesObject *)wf.str);
+	wf.end = wf.ptr + PyBytes_Size(wf.str);
 	wf.error = 0;
 	wf.depth = 0;
 	wf.version = version;
@@ -1076,14 +1076,14 @@
 	w_object(x, &wf);
 	Py_XDECREF(wf.strings);
 	if (wf.str != NULL) {
-		char *base = PyString_AS_STRING((PyStringObject *)wf.str);
+		char *base = PyBytes_AS_STRING((PyBytesObject *)wf.str);
 		if (wf.ptr - base > PY_SSIZE_T_MAX) {
 			Py_DECREF(wf.str);
 			PyErr_SetString(PyExc_OverflowError,
 					"too much marshal data for a string");
 			return NULL;
 		}
-		if (_PyString_Resize(&wf.str, (Py_ssize_t)(wf.ptr - base)) < 0)
+		if (_PyBytes_Resize(&wf.str, (Py_ssize_t)(wf.ptr - base)) < 0)
 			return NULL;
 	}
 	if (wf.error) {
@@ -1132,9 +1132,9 @@
 	if (data == NULL)
 		return NULL;
 	rf.fp = NULL;
-	if (PyString_Check(data)) {
-		rf.ptr = PyString_AS_STRING(data);
-		rf.end = rf.ptr + PyString_GET_SIZE(data);
+	if (PyBytes_Check(data)) {
+		rf.ptr = PyBytes_AS_STRING(data);
+		rf.end = rf.ptr + PyBytes_GET_SIZE(data);
 	}
 	else if (PyByteArray_Check(data)) {
 		rf.ptr = PyByteArray_AS_STRING(data);

Modified: python/branches/py3k/Python/modsupport.c
==============================================================================
--- python/branches/py3k/Python/modsupport.c	(original)
+++ python/branches/py3k/Python/modsupport.c	Mon May 26 15:28:38 2008
@@ -498,7 +498,7 @@
 					}
 					n = (Py_ssize_t)m;
 				}
-				v = PyString_FromStringAndSize(str, n);
+				v = PyBytes_FromStringAndSize(str, n);
 			}
 			return v;
 		}

Modified: python/branches/py3k/Python/peephole.c
==============================================================================
--- python/branches/py3k/Python/peephole.c	(original)
+++ python/branches/py3k/Python/peephole.c	Mon May 26 15:28:38 2008
@@ -325,15 +325,15 @@
 		goto exitUnchanged;
 
 	/* Bypass optimization when the lineno table is too complex */
-	assert(PyString_Check(lineno_obj));
-	lineno = (unsigned char*)PyString_AS_STRING(lineno_obj);
-	tabsiz = PyString_GET_SIZE(lineno_obj);
+	assert(PyBytes_Check(lineno_obj));
+	lineno = (unsigned char*)PyBytes_AS_STRING(lineno_obj);
+	tabsiz = PyBytes_GET_SIZE(lineno_obj);
 	if (memchr(lineno, 255, tabsiz) != NULL)
 		goto exitUnchanged;
 
 	/* Avoid situations where jump retargeting could overflow */
-	assert(PyString_Check(code));
-	codelen = PyString_GET_SIZE(code);
+	assert(PyBytes_Check(code));
+	codelen = PyBytes_GET_SIZE(code);
 	if (codelen > 32700)
 		goto exitUnchanged;
 
@@ -342,7 +342,7 @@
 	if (codestr == NULL)
 		goto exitUnchanged;
 	codestr = (unsigned char *)memcpy(codestr, 
-					  PyString_AS_STRING(code), codelen);
+					  PyBytes_AS_STRING(code), codelen);
 
 	/* Verify that RETURN_VALUE terminates the codestring.	This allows
 	   the various transformation patterns to look ahead several
@@ -632,7 +632,7 @@
 	}
 	assert(h + nops == codelen);
 
-	code = PyString_FromStringAndSize((char *)codestr, h);
+	code = PyBytes_FromStringAndSize((char *)codestr, h);
 	PyMem_Free(addrmap);
 	PyMem_Free(codestr);
 	PyMem_Free(blocks);

Modified: python/branches/py3k/Python/pystrtod.c
==============================================================================
--- python/branches/py3k/Python/pystrtod.c	(original)
+++ python/branches/py3k/Python/pystrtod.c	Mon May 26 15:28:38 2008
@@ -364,7 +364,7 @@
 	/* At this point, p points just past the right-most character we
 	   want to format.  We need to add the grouping string for the
 	   characters between buffer and p. */
-	return _PyString_InsertThousandsGrouping(buffer, len, p,
+	return _PyBytes_InsertThousandsGrouping(buffer, len, p,
 						 buf_size, NULL, 1);
 }
 

Modified: python/branches/py3k/Python/pythonrun.c
==============================================================================
--- python/branches/py3k/Python/pythonrun.c	(original)
+++ python/branches/py3k/Python/pythonrun.c	Mon May 26 15:28:38 2008
@@ -459,7 +459,7 @@
 	PyTuple_Fini();
 	PyList_Fini();
 	PySet_Fini();
-	PyString_Fini();
+	PyBytes_Fini();
 	PyByteArray_Fini();
 	PyLong_Fini();
 	PyFloat_Fini();

Modified: python/branches/py3k/Python/traceback.c
==============================================================================
--- python/branches/py3k/Python/traceback.c	(original)
+++ python/branches/py3k/Python/traceback.c	Mon May 26 15:28:38 2008
@@ -161,12 +161,12 @@
 					PyErr_Clear();
 					break;
 				}
-				if (PyString_Check(v)) {
+				if (PyBytes_Check(v)) {
 					size_t len;
-					len = PyString_GET_SIZE(v);
+					len = PyBytes_GET_SIZE(v);
 					if (len + 1 + taillen >= MAXPATHLEN)
 						continue; /* Too long */
-					strcpy(namebuf, PyString_AsString(v));
+					strcpy(namebuf, PyBytes_AsString(v));
 					if (strlen(namebuf) != len)
 						continue; /* v contains '\0' */
 					if (len > 0 && namebuf[len-1] != SEP)


More information about the Python-3000-checkins mailing list