This reverts r63675 based on the discussion in this thread:
http://mail.python.org/pipermail/python-dev/2008-June/079988.html
Python 2.6 should stick with PyString_* in its codebase. The PyBytes_* names
in the spirit of 3.0 are available via a #define only. See the email thread.
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
index f85b2ef..01971b7 100644
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -153,7 +153,7 @@
{
PyObject *name = hinfo->nameobj;
if (name == NULL) {
- name = PyBytes_FromString(hinfo->name);
+ name = PyString_FromString(hinfo->name);
hinfo->nameobj = name;
}
Py_XINCREF(name);
@@ -205,7 +205,7 @@
Py_INCREF(Py_None);
return Py_None;
}
- return PyBytes_FromString(str);
+ return PyString_FromString(str);
}
static PyObject *
@@ -218,7 +218,7 @@
Py_INCREF(Py_None);
return Py_None;
}
- return PyBytes_FromStringAndSize((const char *)str, len);
+ return PyString_FromStringAndSize((const char *)str, len);
}
/* Callback routines */
@@ -267,16 +267,16 @@
PyObject *filename = NULL;
if (handler_info[slot].tb_code == NULL) {
- code = PyBytes_FromString("");
+ code = PyString_FromString("");
if (code == NULL)
goto failed;
- name = PyBytes_FromString(func_name);
+ name = PyString_FromString(func_name);
if (name == NULL)
goto failed;
nulltuple = PyTuple_New(0);
if (nulltuple == NULL)
goto failed;
- filename = PyBytes_FromString(__FILE__);
+ filename = PyString_FromString(__FILE__);
handler_info[slot].tb_code =
PyCode_New(0, /* argcount */
0, /* nlocals */
@@ -971,13 +971,13 @@
goto finally;
/* XXX what to do if it returns a Unicode string? */
- if (!PyBytes_Check(str)) {
+ if (!PyString_Check(str)) {
PyErr_Format(PyExc_TypeError,
"read() did not return a string object (type=%.400s)",
Py_TYPE(str)->tp_name);
goto finally;
}
- len = PyBytes_GET_SIZE(str);
+ len = PyString_GET_SIZE(str);
if (len > buf_size) {
PyErr_Format(PyExc_ValueError,
"read() returned too much data: "
@@ -985,7 +985,7 @@
buf_size, len);
goto finally;
}
- memcpy(buf, PyBytes_AsString(str), len);
+ memcpy(buf, PyString_AsString(str), len);
finally:
Py_XDECREF(arg);
Py_XDECREF(str);
@@ -1094,7 +1094,7 @@
= XML_GetInputContext(self->itself, &offset, &size);
if (buffer != NULL)
- return PyBytes_FromStringAndSize(buffer + offset,
+ return PyString_FromStringAndSize(buffer + offset,
size - offset);
else
Py_RETURN_NONE;
@@ -1511,7 +1511,7 @@
#define APPEND(list, str) \
do { \
- PyObject *o = PyBytes_FromString(str); \
+ PyObject *o = PyString_FromString(str); \
if (o != NULL) \
PyList_Append(list, o); \
Py_XDECREF(o); \
@@ -1862,7 +1862,7 @@
while (rev[i] != ' ' && rev[i] != '\0')
++i;
- return PyBytes_FromStringAndSize(rev, i);
+ return PyString_FromStringAndSize(rev, i);
}
/* Initialization function for the module */
@@ -1889,7 +1889,7 @@
MODULE_INITFUNC(void)
{
PyObject *m, *d;
- PyObject *errmod_name = PyBytes_FromString(MODULE_NAME ".errors");
+ PyObject *errmod_name = PyString_FromString(MODULE_NAME ".errors");
PyObject *errors_module;
PyObject *modelmod_name;
PyObject *model_module;
@@ -1899,7 +1899,7 @@
if (errmod_name == NULL)
return;
- modelmod_name = PyBytes_FromString(MODULE_NAME ".model");
+ modelmod_name = PyString_FromString(MODULE_NAME ".model");
if (modelmod_name == NULL)
return;