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/Mac/Modules/cf/_CFmodule.c b/Mac/Modules/cf/_CFmodule.c
index 1ea5b7e..0904ae1 100644
--- a/Mac/Modules/cf/_CFmodule.c
+++ b/Mac/Modules/cf/_CFmodule.c
@@ -392,7 +392,7 @@
{
char buf[100];
sprintf(buf, "<CFTypeRef type-%d object at 0x%8.8x for 0x%8.8x>", (int)CFGetTypeID(self->ob_itself), (unsigned)self, (unsigned)self->ob_itself);
- return PyBytes_FromString(buf);
+ return PyString_FromString(buf);
}
static int CFTypeRefObj_hash(CFTypeRefObject *self)
@@ -596,7 +596,7 @@
{
char buf[100];
sprintf(buf, "<CFArrayRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
- return PyBytes_FromString(buf);
+ return PyString_FromString(buf);
}
static int CFArrayRefObj_hash(CFArrayRefObject *self)
@@ -836,7 +836,7 @@
{
char buf[100];
sprintf(buf, "<CFMutableArrayRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
- return PyBytes_FromString(buf);
+ return PyString_FromString(buf);
}
static int CFMutableArrayRefObj_hash(CFMutableArrayRefObject *self)
@@ -1029,7 +1029,7 @@
{
char buf[100];
sprintf(buf, "<CFDictionaryRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
- return PyBytes_FromString(buf);
+ return PyString_FromString(buf);
}
static int CFDictionaryRefObj_hash(CFDictionaryRefObject *self)
@@ -1206,7 +1206,7 @@
{
char buf[100];
sprintf(buf, "<CFMutableDictionaryRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
- return PyBytes_FromString(buf);
+ return PyString_FromString(buf);
}
static int CFMutableDictionaryRefObj_hash(CFMutableDictionaryRefObject *self)
@@ -1327,10 +1327,10 @@
{
if (v == Py_None) { *p_itself = NULL; return 1; }
- if (PyBytes_Check(v)) {
+ if (PyString_Check(v)) {
char *cStr;
Py_ssize_t cLen;
- if( PyBytes_AsStringAndSize(v, &cStr, &cLen) < 0 ) return 0;
+ if( PyString_AsStringAndSize(v, &cStr, &cLen) < 0 ) return 0;
*p_itself = CFDataCreate((CFAllocatorRef)NULL, (unsigned char *)cStr, cLen);
return 1;
}
@@ -1405,7 +1405,7 @@
int size = CFDataGetLength(_self->ob_itself);
char *data = (char *)CFDataGetBytePtr(_self->ob_itself);
- _res = (PyObject *)PyBytes_FromStringAndSize(data, size);
+ _res = (PyObject *)PyString_FromStringAndSize(data, size);
return _res;
}
@@ -1437,7 +1437,7 @@
{
char buf[100];
sprintf(buf, "<CFDataRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
- return PyBytes_FromString(buf);
+ return PyString_FromString(buf);
}
static int CFDataRefObj_hash(CFDataRefObject *self)
@@ -1702,7 +1702,7 @@
{
char buf[100];
sprintf(buf, "<CFMutableDataRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
- return PyBytes_FromString(buf);
+ return PyString_FromString(buf);
}
static int CFMutableDataRefObj_hash(CFMutableDataRefObject *self)
@@ -1823,7 +1823,7 @@
{
if (v == Py_None) { *p_itself = NULL; return 1; }
- if (PyBytes_Check(v)) {
+ if (PyString_Check(v)) {
char *cStr;
if (!PyArg_Parse(v, "es", "ascii", &cStr))
return 0;
@@ -2344,7 +2344,7 @@
if( data == NULL ) return PyErr_NoMemory();
if ( CFStringGetCString(_self->ob_itself, data, size, 0) ) {
- _res = (PyObject *)PyBytes_FromString(data);
+ _res = (PyObject *)PyString_FromString(data);
} else {
PyErr_SetString(PyExc_RuntimeError, "CFStringGetCString could not fit the string");
_res = NULL;
@@ -2445,7 +2445,7 @@
{
char buf[100];
sprintf(buf, "<CFStringRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
- return PyBytes_FromString(buf);
+ return PyString_FromString(buf);
}
static int CFStringRefObj_hash(CFStringRefObject *self)
@@ -2833,7 +2833,7 @@
{
char buf[100];
sprintf(buf, "<CFMutableStringRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
- return PyBytes_FromString(buf);
+ return PyString_FromString(buf);
}
static int CFMutableStringRefObj_hash(CFMutableStringRefObject *self)
@@ -3485,7 +3485,7 @@
{
char buf[100];
sprintf(buf, "<CFURL object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
- return PyBytes_FromString(buf);
+ return PyString_FromString(buf);
}
static int CFURLRefObj_hash(CFURLRefObject *self)
diff --git a/Mac/Modules/cf/pycfbridge.c b/Mac/Modules/cf/pycfbridge.c
index 7aa2386..06700b3 100644
--- a/Mac/Modules/cf/pycfbridge.c
+++ b/Mac/Modules/cf/pycfbridge.c
@@ -146,7 +146,7 @@
int
PyCF_Python2CF(PyObject *src, CFTypeRef *dst) {
- if (PyBytes_Check(src) || PyUnicode_Check(src))
+ if (PyString_Check(src) || PyUnicode_Check(src))
return PyCF_Python2CF_simple(src, dst);
if (PySequence_Check(src))
return PyCF_Python2CF_sequence(src, (CFArrayRef *)dst);
@@ -249,7 +249,7 @@
return (*dst != NULL);
}
#endif
- if (PyBytes_Check(src) || PyUnicode_Check(src))
+ if (PyString_Check(src) || PyUnicode_Check(src))
return PyCF_Python2CF_string(src, (CFStringRef *)dst);
if (PyBool_Check(src)) {
if (src == Py_True)
@@ -281,7 +281,7 @@
CFIndex size;
UniChar *unichars;
- if (PyBytes_Check(src)) {
+ if (PyString_Check(src)) {
if (!PyArg_Parse(src, "es", "ascii", &chars))
return 0; /* This error is more descriptive than the general one below */
*dst = CFStringCreateWithCString((CFAllocatorRef)NULL, chars, kCFStringEncodingASCII);