summaryrefslogtreecommitdiffstats
path: root/Modules/cjkcodecs
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2008-06-09 04:58:54 (GMT)
committerGregory P. Smith <greg@mad-scientist.com>2008-06-09 04:58:54 (GMT)
commitdd96db63f689e2f0d8ae5a1436b3b3395eec7de5 (patch)
treeb2299acac9ce44fc488fc7b2ae2a44548cd5fbb8 /Modules/cjkcodecs
parente98839a1f48b2915f1cc747884e64f4d6e4c8e7a (diff)
downloadcpython-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/cjkcodecs')
-rw-r--r--Modules/cjkcodecs/cjkcodecs.h4
-rw-r--r--Modules/cjkcodecs/multibytecodec.c62
2 files changed, 33 insertions, 33 deletions
diff --git a/Modules/cjkcodecs/cjkcodecs.h b/Modules/cjkcodecs/cjkcodecs.h
index c06319e..4005bcf 100644
--- a/Modules/cjkcodecs/cjkcodecs.h
+++ b/Modules/cjkcodecs/cjkcodecs.h
@@ -261,7 +261,7 @@ getcodec(PyObject *self, PyObject *encoding)
const MultibyteCodec *codec;
const char *enc;
- if (!PyBytes_Check(encoding)) {
+ if (!PyString_Check(encoding)) {
PyErr_SetString(PyExc_TypeError,
"encoding name must be a string.");
return NULL;
@@ -271,7 +271,7 @@ getcodec(PyObject *self, PyObject *encoding)
if (cofunc == NULL)
return NULL;
- enc = PyBytes_AS_STRING(encoding);
+ enc = PyString_AS_STRING(encoding);
for (codec = codec_list; codec->encoding[0]; codec++)
if (strcmp(codec->encoding, enc) == 0)
break;
diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c
index e70ec53..bbd4c1a 100644
--- a/Modules/cjkcodecs/multibytecodec.c
+++ b/Modules/cjkcodecs/multibytecodec.c
@@ -85,7 +85,7 @@ internal_error_callback(const char *errors)
else if (strcmp(errors, "replace") == 0)
return ERROR_REPLACE;
else
- return PyBytes_FromString(errors);
+ return PyString_FromString(errors);
}
static PyObject *
@@ -93,8 +93,8 @@ call_error_callback(PyObject *errors, PyObject *exc)
{
PyObject *args, *cb, *r;
- assert(PyBytes_Check(errors));
- cb = PyCodec_LookupError(PyBytes_AS_STRING(errors));
+ assert(PyString_Check(errors));
+ cb = PyCodec_LookupError(PyString_AS_STRING(errors));
if (cb == NULL)
return NULL;
@@ -129,7 +129,7 @@ codecctx_errors_get(MultibyteStatefulCodecContext *self)
return self->errors;
}
- return PyBytes_FromString(errors);
+ return PyString_FromString(errors);
}
static int
@@ -138,12 +138,12 @@ codecctx_errors_set(MultibyteStatefulCodecContext *self, PyObject *value,
{
PyObject *cb;
- if (!PyBytes_Check(value)) {
+ if (!PyString_Check(value)) {
PyErr_SetString(PyExc_TypeError, "errors must be a string");
return -1;
}
- cb = internal_error_callback(PyBytes_AS_STRING(value));
+ cb = internal_error_callback(PyString_AS_STRING(value));
if (cb == NULL)
return -1;
@@ -166,15 +166,15 @@ expand_encodebuffer(MultibyteEncodeBuffer *buf, Py_ssize_t esize)
Py_ssize_t orgpos, orgsize;
orgpos = (Py_ssize_t)((char *)buf->outbuf -
- PyBytes_AS_STRING(buf->outobj));
- orgsize = PyBytes_GET_SIZE(buf->outobj);
- if (_PyBytes_Resize(&buf->outobj, orgsize + (
+ PyString_AS_STRING(buf->outobj));
+ orgsize = PyString_GET_SIZE(buf->outobj);
+ if (_PyString_Resize(&buf->outobj, orgsize + (
esize < (orgsize >> 1) ? (orgsize >> 1) | 1 : esize)) == -1)
return -1;
- 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);
+ 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);
return 0;
}
@@ -322,10 +322,10 @@ multibytecodec_encerror(MultibyteCodec *codec,
goto errorexit;
}
- retstrsize = PyBytes_GET_SIZE(retstr);
+ retstrsize = PyString_GET_SIZE(retstr);
REQUIRE_ENCODEBUFFER(buf, retstrsize);
- memcpy(buf->outbuf, PyBytes_AS_STRING(retstr), retstrsize);
+ memcpy(buf->outbuf, PyString_AS_STRING(retstr), retstrsize);
buf->outbuf += retstrsize;
newpos = PyInt_AsSsize_t(PyTuple_GET_ITEM(retobj, 1));
@@ -468,16 +468,16 @@ multibytecodec_encode(MultibyteCodec *codec,
Py_ssize_t finalsize, r = 0;
if (datalen == 0)
- return PyBytes_FromString("");
+ return PyString_FromString("");
buf.excobj = NULL;
buf.inbuf = buf.inbuf_top = *data;
buf.inbuf_end = buf.inbuf_top + datalen;
- buf.outobj = PyBytes_FromStringAndSize(NULL, datalen * 2 + 16);
+ buf.outobj = PyString_FromStringAndSize(NULL, datalen * 2 + 16);
if (buf.outobj == NULL)
goto errorexit;
- buf.outbuf = (unsigned char *)PyBytes_AS_STRING(buf.outobj);
- buf.outbuf_end = buf.outbuf + PyBytes_GET_SIZE(buf.outobj);
+ buf.outbuf = (unsigned char *)PyString_AS_STRING(buf.outobj);
+ buf.outbuf_end = buf.outbuf + PyString_GET_SIZE(buf.outobj);
while (buf.inbuf < buf.inbuf_end) {
Py_ssize_t inleft, outleft;
@@ -512,10 +512,10 @@ multibytecodec_encode(MultibyteCodec *codec,
}
finalsize = (Py_ssize_t)((char *)buf.outbuf -
- PyBytes_AS_STRING(buf.outobj));
+ PyString_AS_STRING(buf.outobj));
- if (finalsize != PyBytes_GET_SIZE(buf.outobj))
- if (_PyBytes_Resize(&buf.outobj, finalsize) == -1)
+ if (finalsize != PyString_GET_SIZE(buf.outobj))
+ if (_PyString_Resize(&buf.outobj, finalsize) == -1)
goto errorexit;
Py_XDECREF(buf.excobj);
@@ -1222,35 +1222,35 @@ mbstreamreader_iread(MultibyteStreamReaderObject *self,
if (cres == NULL)
goto errorexit;
- if (!PyBytes_Check(cres)) {
+ if (!PyString_Check(cres)) {
PyErr_SetString(PyExc_TypeError,
"stream function returned a "
"non-string object");
goto errorexit;
}
- endoffile = (PyBytes_GET_SIZE(cres) == 0);
+ endoffile = (PyString_GET_SIZE(cres) == 0);
if (self->pendingsize > 0) {
PyObject *ctr;
char *ctrdata;
- rsize = PyBytes_GET_SIZE(cres) + self->pendingsize;
- ctr = PyBytes_FromStringAndSize(NULL, rsize);
+ rsize = PyString_GET_SIZE(cres) + self->pendingsize;
+ ctr = PyString_FromStringAndSize(NULL, rsize);
if (ctr == NULL)
goto errorexit;
- ctrdata = PyBytes_AS_STRING(ctr);
+ ctrdata = PyString_AS_STRING(ctr);
memcpy(ctrdata, self->pending, self->pendingsize);
memcpy(ctrdata + self->pendingsize,
- PyBytes_AS_STRING(cres),
- PyBytes_GET_SIZE(cres));
+ PyString_AS_STRING(cres),
+ PyString_GET_SIZE(cres));
Py_DECREF(cres);
cres = ctr;
self->pendingsize = 0;
}
- rsize = PyBytes_GET_SIZE(cres);
- if (decoder_prepare_buffer(&buf, PyBytes_AS_STRING(cres),
+ rsize = PyString_GET_SIZE(cres);
+ if (decoder_prepare_buffer(&buf, PyString_AS_STRING(cres),
rsize) != 0)
goto errorexit;
@@ -1585,7 +1585,7 @@ mbstreamwriter_reset(MultibyteStreamWriterObject *self)
if (pwrt == NULL)
return NULL;
- if (PyBytes_Size(pwrt) > 0) {
+ if (PyString_Size(pwrt) > 0) {
PyObject *wr;
wr = PyObject_CallMethod(self->stream, "write", "O", pwrt);
if (wr == NULL) {