diff options
author | Gregory P. Smith <greg@mad-scientist.com> | 2008-06-09 04:58:54 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@mad-scientist.com> | 2008-06-09 04:58:54 (GMT) |
commit | dd96db63f689e2f0d8ae5a1436b3b3395eec7de5 (patch) | |
tree | b2299acac9ce44fc488fc7b2ae2a44548cd5fbb8 /Modules/_ctypes | |
parent | e98839a1f48b2915f1cc747884e64f4d6e4c8e7a (diff) | |
download | cpython-dd96db63f689e2f0d8ae5a1436b3b3395eec7de5.zip cpython-dd96db63f689e2f0d8ae5a1436b3b3395eec7de5.tar.gz cpython-dd96db63f689e2f0d8ae5a1436b3b3395eec7de5.tar.bz2 |
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.
Diffstat (limited to 'Modules/_ctypes')
-rw-r--r-- | Modules/_ctypes/_ctypes.c | 104 | ||||
-rw-r--r-- | Modules/_ctypes/callbacks.c | 10 | ||||
-rw-r--r-- | Modules/_ctypes/callproc.c | 30 | ||||
-rw-r--r-- | Modules/_ctypes/cfield.c | 36 |
4 files changed, 90 insertions, 90 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 18851fd..73542c7 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -714,8 +714,8 @@ StructType_setattro(PyObject *self, PyObject *key, PyObject *value) if (-1 == PyType_Type.tp_setattro(self, key, value)) return -1; - if (value && PyBytes_Check(key) && - 0 == strcmp(PyBytes_AS_STRING(key), "_fields_")) + if (value && PyString_Check(key) && + 0 == strcmp(PyString_AS_STRING(key), "_fields_")) return StructUnionType_update_stgdict(self, value, 1); return 0; } @@ -728,8 +728,8 @@ UnionType_setattro(PyObject *self, PyObject *key, PyObject *value) if (-1 == PyObject_GenericSetAttr(self, key, value)) return -1; - if (PyBytes_Check(key) && - 0 == strcmp(PyBytes_AS_STRING(key), "_fields_")) + if (PyString_Check(key) && + 0 == strcmp(PyString_AS_STRING(key), "_fields_")) return StructUnionType_update_stgdict(self, value, 0); return 0; } @@ -1065,7 +1065,7 @@ CharArray_set_raw(CDataObject *self, PyObject *value) size = Py_TYPE(value)->tp_as_buffer->bf_getreadbuffer(value, 0, (void *)&ptr); if (size < 0) return -1; - } else if (-1 == PyBytes_AsStringAndSize(value, &ptr, &size)) { + } else if (-1 == PyString_AsStringAndSize(value, &ptr, &size)) { return -1; } if (size > self->b_size) { @@ -1082,7 +1082,7 @@ CharArray_set_raw(CDataObject *self, PyObject *value) static PyObject * CharArray_get_raw(CDataObject *self) { - return PyBytes_FromStringAndSize(self->b_ptr, self->b_size); + return PyString_FromStringAndSize(self->b_ptr, self->b_size); } static PyObject * @@ -1093,7 +1093,7 @@ CharArray_get_value(CDataObject *self) for (i = 0; i < self->b_size; ++i) if (*ptr++ == '\0') break; - return PyBytes_FromStringAndSize(self->b_ptr, i); + return PyString_FromStringAndSize(self->b_ptr, i); } static int @@ -1114,14 +1114,14 @@ CharArray_set_value(CDataObject *self, PyObject *value) conversion_mode_errors); if (!value) return -1; - } else if (!PyBytes_Check(value)) { + } else if (!PyString_Check(value)) { PyErr_Format(PyExc_TypeError, "string expected instead of %s instance", Py_TYPE(value)->tp_name); return -1; } else Py_INCREF(value); - size = PyBytes_GET_SIZE(value); + size = PyString_GET_SIZE(value); if (size > self->b_size) { PyErr_SetString(PyExc_ValueError, "string too long"); @@ -1129,7 +1129,7 @@ CharArray_set_value(CDataObject *self, PyObject *value) return -1; } - ptr = PyBytes_AS_STRING(value); + ptr = PyString_AS_STRING(value); memcpy(self->b_ptr, ptr, size); if (size < self->b_size) self->b_ptr[size] = '\0'; @@ -1168,7 +1168,7 @@ WCharArray_set_value(CDataObject *self, PyObject *value) "can't delete attribute"); return -1; } - if (PyBytes_Check(value)) { + if (PyString_Check(value)) { value = PyUnicode_FromEncodedObject(value, conversion_mode_encoding, conversion_mode_errors); @@ -1465,7 +1465,7 @@ c_wchar_p_from_param(PyObject *type, PyObject *value) Py_INCREF(Py_None); return Py_None; } - if (PyUnicode_Check(value) || PyBytes_Check(value)) { + if (PyUnicode_Check(value) || PyString_Check(value)) { PyCArgObject *parg; struct fielddesc *fd = getentry("Z"); @@ -1529,7 +1529,7 @@ c_char_p_from_param(PyObject *type, PyObject *value) Py_INCREF(Py_None); return Py_None; } - if (PyBytes_Check(value) || PyUnicode_Check(value)) { + if (PyString_Check(value) || PyUnicode_Check(value)) { PyCArgObject *parg; struct fielddesc *fd = getentry("z"); @@ -1615,7 +1615,7 @@ c_void_p_from_param(PyObject *type, PyObject *value) return (PyObject *)parg; } /* string */ - if (PyBytes_Check(value)) { + if (PyString_Check(value)) { PyCArgObject *parg; struct fielddesc *fd = getentry("z"); @@ -1686,10 +1686,10 @@ c_void_p_from_param(PyObject *type, PyObject *value) } /* c_char_p, c_wchar_p */ stgd = PyObject_stgdict(value); - if (stgd && CDataObject_Check(value) && stgd->proto && PyBytes_Check(stgd->proto)) { + if (stgd && CDataObject_Check(value) && stgd->proto && PyString_Check(stgd->proto)) { PyCArgObject *parg; - switch (PyBytes_AS_STRING(stgd->proto)[0]) { + switch (PyString_AS_STRING(stgd->proto)[0]) { case 'z': /* c_char_p */ case 'Z': /* c_wchar_p */ parg = new_CArgObject(); @@ -1746,13 +1746,13 @@ static PyObject *CreateSwappedType(PyTypeObject *type, PyObject *args, PyObject if (suffix == NULL) #ifdef WORDS_BIGENDIAN - suffix = PyBytes_InternFromString("_le"); + suffix = PyString_InternFromString("_le"); #else - suffix = PyBytes_InternFromString("_be"); + suffix = PyString_InternFromString("_be"); #endif Py_INCREF(name); - PyBytes_Concat(&name, suffix); + PyString_Concat(&name, suffix); if (name == NULL) return NULL; @@ -1807,7 +1807,7 @@ SimpleType_paramfunc(CDataObject *self) dict = PyObject_stgdict((PyObject *)self); assert(dict); /* Cannot be NULL for CDataObject instances */ - fmt = PyBytes_AsString(dict->proto); + fmt = PyString_AsString(dict->proto); assert(fmt); fd = getentry(fmt); @@ -1872,12 +1872,12 @@ SimpleType_new(PyTypeObject *type, PyObject *args, PyObject *kwds) SIMPLE_TYPE_CHARS); goto error; } - fmt = getentry(PyBytes_AS_STRING(proto)); + fmt = getentry(PyString_AS_STRING(proto)); if (fmt == NULL) { Py_DECREF(result); PyErr_Format(PyExc_ValueError, "_type_ '%s' not supported", - PyBytes_AS_STRING(proto)); + PyString_AS_STRING(proto)); return NULL; } @@ -1927,7 +1927,7 @@ SimpleType_new(PyTypeObject *type, PyObject *args, PyObject *kwds) Overrides the SimpleType_from_param generic method. */ if (result->tp_base == &Simple_Type) { - switch (PyBytes_AS_STRING(proto)[0]) { + switch (PyString_AS_STRING(proto)[0]) { case 'z': /* c_char_p */ ml = &c_char_p_method; stgdict->flags |= TYPEFLAG_ISPOINTER; @@ -2042,7 +2042,7 @@ SimpleType_from_param(PyObject *type, PyObject *value) assert(dict); /* I think we can rely on this being a one-character string */ - fmt = PyBytes_AsString(dict->proto); + fmt = PyString_AsString(dict->proto); assert(fmt); fd = getentry(fmt); @@ -2399,7 +2399,7 @@ unique_key(CDataObject *target, Py_ssize_t index) #endif target = target->b_base; } - return PyBytes_FromStringAndSize(string, cp-string); + return PyString_FromStringAndSize(string, cp-string); } /* @@ -2571,7 +2571,7 @@ CData_reduce(PyObject *_self, PyObject *args) _unpickle, Py_TYPE(_self), PyObject_GetAttrString(_self, "__dict__"), - PyBytes_FromStringAndSize(self->b_ptr, self->b_size)); + PyString_FromStringAndSize(self->b_ptr, self->b_size)); } static PyObject * @@ -3120,9 +3120,9 @@ _check_outarg_type(PyObject *arg, Py_ssize_t index) dict = PyType_stgdict(arg); if (dict /* simple pointer types, c_void_p, c_wchar_p, BSTR, ... */ - && PyBytes_Check(dict->proto) + && PyString_Check(dict->proto) /* We only allow c_void_p, c_char_p and c_wchar_p as a simple output parameter type */ - && (strchr("PzZ", PyBytes_AS_STRING(dict->proto)[0]))) { + && (strchr("PzZ", PyString_AS_STRING(dict->proto)[0]))) { return 1; } @@ -3207,8 +3207,8 @@ _get_name(PyObject *obj, char **pname) return 1; } #endif - if (PyBytes_Check(obj) || PyUnicode_Check(obj)) { - *pname = PyBytes_AsString(obj); + if (PyString_Check(obj) || PyUnicode_Check(obj)) { + *pname = PyString_AsString(obj); return *pname ? 1 : 0; } PyErr_SetString(PyExc_TypeError, @@ -3558,7 +3558,7 @@ _build_callargs(CFuncPtrObject *self, PyObject *argtypes, /* We HAVE already checked that the tuple can be parsed with "i|zO", so... */ Py_ssize_t tsize = PyTuple_GET_SIZE(item); flag = PyInt_AS_LONG(PyTuple_GET_ITEM(item, 0)); - name = tsize > 1 ? PyBytes_AS_STRING(PyTuple_GET_ITEM(item, 1)) : NULL; + name = tsize > 1 ? PyString_AS_STRING(PyTuple_GET_ITEM(item, 1)) : NULL; defval = tsize > 2 ? PyTuple_GET_ITEM(item, 2) : NULL; switch (flag & (PARAMFLAG_FIN | PARAMFLAG_FOUT | PARAMFLAG_FLCID)) { @@ -3612,7 +3612,7 @@ _build_callargs(CFuncPtrObject *self, PyObject *argtypes, "NULL stgdict unexpected"); goto error; } - if (PyBytes_Check(dict->proto)) { + if (PyString_Check(dict->proto)) { PyErr_Format( PyExc_TypeError, "%s 'out' parameter must be passed as default value", @@ -3910,12 +3910,12 @@ CFuncPtr_repr(CFuncPtrObject *self) { #ifdef MS_WIN32 if (self->index) - return PyBytes_FromFormat("<COM method offset %d: %s at %p>", + return PyString_FromFormat("<COM method offset %d: %s at %p>", self->index - 0x1000, Py_TYPE(self)->tp_name, self); #endif - return PyBytes_FromFormat("<%s object at %p>", + return PyString_FromFormat("<%s object at %p>", Py_TYPE(self)->tp_name, self); } @@ -4044,7 +4044,7 @@ Struct_init(PyObject *self, PyObject *args, PyObject *kwds) } if (kwds && PyDict_GetItem(kwds, name)) { - char *field = PyBytes_AsString(name); + char *field = PyString_AsString(name); if (field == NULL) { PyErr_Clear(); field = "???"; @@ -4246,7 +4246,7 @@ Array_slice(PyObject *_self, Py_ssize_t ilow, Py_ssize_t ihigh) type, so this cannot be NULL */ if (itemdict->getfunc == getentry("c")->getfunc) { char *ptr = (char *)self->b_ptr; - return PyBytes_FromStringAndSize(ptr + ilow, len); + return PyString_FromStringAndSize(ptr + ilow, len); #ifdef CTYPES_UNICODE } else if (itemdict->getfunc == getentry("u")->getfunc) { wchar_t *ptr = (wchar_t *)self->b_ptr; @@ -4303,9 +4303,9 @@ Array_subscript(PyObject *_self, PyObject *item) char *dest; if (slicelen <= 0) - return PyBytes_FromString(""); + return PyString_FromString(""); if (step == 1) { - return PyBytes_FromStringAndSize(ptr + start, + return PyString_FromStringAndSize(ptr + start, slicelen); } dest = (char *)PyMem_Malloc(slicelen); @@ -4318,7 +4318,7 @@ Array_subscript(PyObject *_self, PyObject *item) dest[i] = ptr[cur]; } - np = PyBytes_FromStringAndSize(dest, slicelen); + np = PyString_FromStringAndSize(dest, slicelen); PyMem_Free(dest); return np; } @@ -4728,12 +4728,12 @@ Simple_repr(CDataObject *self) static PyObject *format; if (Py_TYPE(self)->tp_base != &Simple_Type) { - return PyBytes_FromFormat("<%s object at %p>", + return PyString_FromFormat("<%s object at %p>", Py_TYPE(self)->tp_name, self); } if (format == NULL) { - format = PyBytes_InternFromString("%s(%r)"); + format = PyString_InternFromString("%s(%r)"); if (format == NULL) return NULL; } @@ -4742,7 +4742,7 @@ Simple_repr(CDataObject *self) if (val == NULL) return NULL; - name = PyBytes_FromString(Py_TYPE(self)->tp_name); + name = PyString_FromString(Py_TYPE(self)->tp_name); if (name == NULL) { Py_DECREF(val); return NULL; @@ -4754,7 +4754,7 @@ Simple_repr(CDataObject *self) if (args == NULL) return NULL; - result = PyBytes_Format(format, args); + result = PyString_Format(format, args); Py_DECREF(args); return result; } @@ -4988,7 +4988,7 @@ Pointer_slice(PyObject *_self, Py_ssize_t ilow, Py_ssize_t ihigh) assert(itemdict); if (itemdict->getfunc == getentry("c")->getfunc) { char *ptr = *(char **)self->b_ptr; - return PyBytes_FromStringAndSize(ptr + ilow, len); + return PyString_FromStringAndSize(ptr + ilow, len); #ifdef CTYPES_UNICODE } else if (itemdict->getfunc == getentry("u")->getfunc) { wchar_t *ptr = *(wchar_t **)self->b_ptr; @@ -5085,9 +5085,9 @@ Pointer_subscript(PyObject *_self, PyObject *item) char *dest; if (len <= 0) - return PyBytes_FromString(""); + return PyString_FromString(""); if (step == 1) { - return PyBytes_FromStringAndSize(ptr + start, + return PyString_FromStringAndSize(ptr + start, len); } dest = (char *)PyMem_Malloc(len); @@ -5096,7 +5096,7 @@ Pointer_subscript(PyObject *_self, PyObject *item) for (cur = start, i = 0; i < len; cur += step, i++) { dest[i] = ptr[cur]; } - np = PyBytes_FromStringAndSize(dest, len); + np = PyString_FromStringAndSize(dest, len); PyMem_Free(dest); return np; } @@ -5276,7 +5276,7 @@ create_comerror(void) ++methods; } - s = PyBytes_FromString(comerror_doc); + s = PyString_FromString(comerror_doc); if (s == NULL) goto error; status = PyDict_SetItemString(dict, "__doc__", s); @@ -5302,8 +5302,8 @@ static PyObject * string_at(const char *ptr, int size) { if (size == -1) - return PyBytes_FromString(ptr); - return PyBytes_FromStringAndSize(ptr, size); + return PyString_FromString(ptr); + return PyString_FromStringAndSize(ptr, size); } static int @@ -5317,8 +5317,8 @@ cast_check_pointertype(PyObject *arg) return 1; dict = PyType_stgdict(arg); if (dict) { - if (PyBytes_Check(dict->proto) - && (strchr("sPzUZXO", PyBytes_AS_STRING(dict->proto)[0]))) { + if (PyString_Check(dict->proto) + && (strchr("sPzUZXO", PyString_AS_STRING(dict->proto)[0]))) { /* simple pointer types, c_void_p, c_wchar_p, BSTR, ... */ return 1; } diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c index aa02154..0f8c8fa 100644 --- a/Modules/_ctypes/callbacks.c +++ b/Modules/_ctypes/callbacks.c @@ -107,15 +107,15 @@ void _AddTraceback(char *funcname, char *filename, int lineno) PyCodeObject *py_code = 0; PyFrameObject *py_frame = 0; - py_srcfile = PyBytes_FromString(filename); + py_srcfile = PyString_FromString(filename); if (!py_srcfile) goto bad; - py_funcname = PyBytes_FromString(funcname); + py_funcname = PyString_FromString(funcname); if (!py_funcname) goto bad; py_globals = PyDict_New(); if (!py_globals) goto bad; empty_tuple = PyTuple_New(0); if (!empty_tuple) goto bad; - empty_string = PyBytes_FromString(""); + empty_string = PyString_FromString(""); if (!empty_string) goto bad; py_code = PyCode_New( 0, /*int argcount,*/ @@ -498,7 +498,7 @@ long Call_GetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) static PyObject *context; if (context == NULL) - context = PyBytes_InternFromString("_ctypes.DllGetClassObject"); + context = PyString_InternFromString("_ctypes.DllGetClassObject"); mod = PyImport_ImportModuleNoBlock("ctypes"); if (!mod) { @@ -577,7 +577,7 @@ long Call_CanUnloadNow(void) static PyObject *context; if (context == NULL) - context = PyBytes_InternFromString("_ctypes.DllCanUnloadNow"); + context = PyString_InternFromString("_ctypes.DllCanUnloadNow"); mod = PyImport_ImportModuleNoBlock("ctypes"); if (!mod) { diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c index 12b0d7a..825a2c7 100644 --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -498,7 +498,7 @@ PyCArg_repr(PyCArgObject *self) self->tag, self); break; } - return PyBytes_FromString(buffer); + return PyString_FromString(buffer); } static PyMemberDef PyCArgType_members[] = { @@ -646,9 +646,9 @@ static int ConvParam(PyObject *obj, Py_ssize_t index, struct argument *pa) return 0; } - if (PyBytes_Check(obj)) { + if (PyString_Check(obj)) { pa->ffi_type = &ffi_type_pointer; - pa->value.p = PyBytes_AS_STRING(obj); + pa->value.p = PyString_AS_STRING(obj); Py_INCREF(obj); pa->keep = obj; return 0; @@ -937,7 +937,7 @@ void Extend_Error_Info(PyObject *exc_class, char *fmt, ...) PyObject *tp, *v, *tb, *s, *cls_str, *msg_str; va_start(vargs, fmt); - s = PyBytes_FromFormatV(fmt, vargs); + s = PyString_FromFormatV(fmt, vargs); va_end(vargs); if (!s) return; @@ -946,18 +946,18 @@ void Extend_Error_Info(PyObject *exc_class, char *fmt, ...) PyErr_NormalizeException(&tp, &v, &tb); cls_str = PyObject_Str(tp); if (cls_str) { - PyBytes_ConcatAndDel(&s, cls_str); - PyBytes_ConcatAndDel(&s, PyBytes_FromString(": ")); + PyString_ConcatAndDel(&s, cls_str); + PyString_ConcatAndDel(&s, PyString_FromString(": ")); if (s == NULL) goto error; } else PyErr_Clear(); msg_str = PyObject_Str(v); if (msg_str) - PyBytes_ConcatAndDel(&s, msg_str); + PyString_ConcatAndDel(&s, msg_str); else { PyErr_Clear(); - PyBytes_ConcatAndDel(&s, PyBytes_FromString("???")); + PyString_ConcatAndDel(&s, PyString_FromString("???")); if (s == NULL) goto error; } @@ -1261,7 +1261,7 @@ static PyObject *load_library(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "O|O:LoadLibrary", &nameobj, &ignored)) return NULL; #ifdef _UNICODE - name = alloca((PyBytes_Size(nameobj) + 1) * sizeof(WCHAR)); + name = alloca((PyString_Size(nameobj) + 1) * sizeof(WCHAR)); if (!name) { PyErr_NoMemory(); return NULL; @@ -1269,14 +1269,14 @@ static PyObject *load_library(PyObject *self, PyObject *args) { int r; - char *aname = PyBytes_AsString(nameobj); + char *aname = PyString_AsString(nameobj); if(!aname) return NULL; - r = MultiByteToWideChar(CP_ACP, 0, aname, -1, name, PyBytes_Size(nameobj) + 1); + r = MultiByteToWideChar(CP_ACP, 0, aname, -1, name, PyString_Size(nameobj) + 1); name[r] = 0; } #else - name = PyBytes_AsString(nameobj); + name = PyString_AsString(nameobj); if(!name) return NULL; #endif @@ -1769,9 +1769,9 @@ POINTER(PyObject *self, PyObject *cls) Py_INCREF(result); return result; } - if (PyBytes_CheckExact(cls)) { - buf = alloca(strlen(PyBytes_AS_STRING(cls)) + 3 + 1); - sprintf(buf, "LP_%s", PyBytes_AS_STRING(cls)); + if (PyString_CheckExact(cls)) { + buf = alloca(strlen(PyString_AS_STRING(cls)) + 3 + 1); + sprintf(buf, "LP_%s", PyString_AS_STRING(cls)); result = PyObject_CallFunction((PyObject *)Py_TYPE(&Pointer_Type), "s(O){}", buf, diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c index 5105493..ba837ec 100644 --- a/Modules/_ctypes/cfield.c +++ b/Modules/_ctypes/cfield.c @@ -272,7 +272,7 @@ CField_repr(CFieldObject *self) name = ((PyTypeObject *)self->proto)->tp_name; if (bits) - result = PyBytes_FromFormat( + result = PyString_FromFormat( #if (PY_VERSION_HEX < 0x02050000) "<Field type=%s, ofs=%d:%d, bits=%d>", #else @@ -280,7 +280,7 @@ CField_repr(CFieldObject *self) #endif name, self->offset, size, bits); else - result = PyBytes_FromFormat( + result = PyString_FromFormat( #if (PY_VERSION_HEX < 0x02050000) "<Field type=%s, ofs=%d, size=%d>", #else @@ -1164,12 +1164,12 @@ O_set(void *ptr, PyObject *value, Py_ssize_t size) static PyObject * c_set(void *ptr, PyObject *value, Py_ssize_t size) { - if (!PyBytes_Check(value) || (1 != PyBytes_Size(value))) { + if (!PyString_Check(value) || (1 != PyString_Size(value))) { PyErr_Format(PyExc_TypeError, "one character string expected"); return NULL; } - *(char *)ptr = PyBytes_AS_STRING(value)[0]; + *(char *)ptr = PyString_AS_STRING(value)[0]; _RET(value); } @@ -1177,7 +1177,7 @@ c_set(void *ptr, PyObject *value, Py_ssize_t size) static PyObject * c_get(void *ptr, Py_ssize_t size) { - return PyBytes_FromStringAndSize((char *)ptr, 1); + return PyString_FromStringAndSize((char *)ptr, 1); } #ifdef CTYPES_UNICODE @@ -1187,7 +1187,7 @@ u_set(void *ptr, PyObject *value, Py_ssize_t size) { Py_ssize_t len; - if (PyBytes_Check(value)) { + if (PyString_Check(value)) { value = PyUnicode_FromEncodedObject(value, conversion_mode_encoding, conversion_mode_errors); @@ -1262,7 +1262,7 @@ U_set(void *ptr, PyObject *value, Py_ssize_t length) /* It's easier to calculate in characters than in bytes */ length /= sizeof(wchar_t); - if (PyBytes_Check(value)) { + if (PyString_Check(value)) { value = PyUnicode_FromEncodedObject(value, conversion_mode_encoding, conversion_mode_errors); @@ -1301,21 +1301,21 @@ s_get(void *ptr, Py_ssize_t size) PyObject *result; size_t slen; - result = PyBytes_FromString((char *)ptr); + result = PyString_FromString((char *)ptr); if (!result) return NULL; /* chop off at the first NUL character, if any. * On error, result will be deallocated and set to NULL. */ - slen = strlen(PyBytes_AS_STRING(result)); + slen = strlen(PyString_AS_STRING(result)); size = min(size, (Py_ssize_t)slen); if (result->ob_refcnt == 1) { /* shorten the result */ - _PyBytes_Resize(&result, size); + _PyString_Resize(&result, size); return result; } else /* cannot shorten the result */ - return PyBytes_FromStringAndSize(ptr, size); + return PyString_FromStringAndSize(ptr, size); } static PyObject * @@ -1324,7 +1324,7 @@ s_set(void *ptr, PyObject *value, Py_ssize_t length) char *data; Py_ssize_t size; - data = PyBytes_AsString(value); + data = PyString_AsString(value); if (!data) return NULL; size = strlen(data); @@ -1356,8 +1356,8 @@ z_set(void *ptr, PyObject *value, Py_ssize_t size) Py_INCREF(value); return value; } - if (PyBytes_Check(value)) { - *(char **)ptr = PyBytes_AS_STRING(value); + if (PyString_Check(value)) { + *(char **)ptr = PyString_AS_STRING(value); Py_INCREF(value); return value; } else if (PyUnicode_Check(value)) { @@ -1366,7 +1366,7 @@ z_set(void *ptr, PyObject *value, Py_ssize_t size) conversion_mode_errors); if (str == NULL) return NULL; - *(char **)ptr = PyBytes_AS_STRING(str); + *(char **)ptr = PyString_AS_STRING(str); return str; } else if (PyInt_Check(value) || PyLong_Check(value)) { #if SIZEOF_VOID_P == SIZEOF_LONG_LONG @@ -1395,7 +1395,7 @@ z_get(void *ptr, Py_ssize_t size) return NULL; } #endif - return PyBytes_FromString(*(char **)ptr); + return PyString_FromString(*(char **)ptr); } else { Py_INCREF(Py_None); return Py_None; @@ -1411,7 +1411,7 @@ Z_set(void *ptr, PyObject *value, Py_ssize_t size) Py_INCREF(value); return value; } - if (PyBytes_Check(value)) { + if (PyString_Check(value)) { value = PyUnicode_FromEncodedObject(value, conversion_mode_encoding, conversion_mode_errors); @@ -1502,7 +1502,7 @@ BSTR_set(void *ptr, PyObject *value, Py_ssize_t size) /* convert value into a PyUnicodeObject or NULL */ if (Py_None == value) { value = NULL; - } else if (PyBytes_Check(value)) { + } else if (PyString_Check(value)) { value = PyUnicode_FromEncodedObject(value, conversion_mode_encoding, conversion_mode_errors); |