summaryrefslogtreecommitdiffstats
path: root/Modules/_json.c
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/_json.c
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/_json.c')
-rw-r--r--Modules/_json.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/Modules/_json.c b/Modules/_json.c
index 30cdc0f..ea6d66f 100644
--- a/Modules/_json.c
+++ b/Modules/_json.c
@@ -70,11 +70,11 @@ ascii_escape_unicode(PyObject *pystr)
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 = PyBytes_FromStringAndSize(NULL, output_size);
+ rval = PyString_FromStringAndSize(NULL, output_size);
if (rval == NULL) {
return NULL;
}
- output = PyBytes_AS_STRING(rval);
+ output = PyString_AS_STRING(rval);
chars = 0;
output[chars++] = '"';
for (i = 0; i < input_chars; i++) {
@@ -92,14 +92,14 @@ ascii_escape_unicode(PyObject *pystr)
if (output_size > 2 + (input_chars * MAX_EXPANSION)) {
output_size = 2 + (input_chars * MAX_EXPANSION);
}
- if (_PyBytes_Resize(&rval, output_size) == -1) {
+ if (_PyString_Resize(&rval, output_size) == -1) {
return NULL;
}
- output = PyBytes_AS_STRING(rval);
+ output = PyString_AS_STRING(rval);
}
}
output[chars++] = '"';
- if (_PyBytes_Resize(&rval, chars) == -1) {
+ if (_PyString_Resize(&rval, chars) == -1) {
return NULL;
}
return rval;
@@ -116,15 +116,15 @@ ascii_escape_str(PyObject *pystr)
char *output;
char *input_str;
- input_chars = PyBytes_GET_SIZE(pystr);
- input_str = PyBytes_AS_STRING(pystr);
+ input_chars = PyString_GET_SIZE(pystr);
+ input_str = PyString_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 = PyBytes_FromStringAndSize(NULL, output_size);
+ rval = PyString_FromStringAndSize(NULL, output_size);
if (rval == NULL) {
return NULL;
}
- output = PyBytes_AS_STRING(rval);
+ output = PyString_AS_STRING(rval);
chars = 0;
output[chars++] = '"';
for (i = 0; i < input_chars; i++) {
@@ -154,14 +154,14 @@ ascii_escape_str(PyObject *pystr)
if (output_size > 2 + (input_chars * MIN_EXPANSION)) {
output_size = 2 + (input_chars * MIN_EXPANSION);
}
- if (_PyBytes_Resize(&rval, output_size) == -1) {
+ if (_PyString_Resize(&rval, output_size) == -1) {
return NULL;
}
- output = PyBytes_AS_STRING(rval);
+ output = PyString_AS_STRING(rval);
}
}
output[chars++] = '"';
- if (_PyBytes_Resize(&rval, chars) == -1) {
+ if (_PyString_Resize(&rval, chars) == -1) {
return NULL;
}
return rval;
@@ -215,7 +215,7 @@ join_list_unicode(PyObject *lst)
ustr = PyUnicode_FromUnicode(&c, 0);
}
if (joinstr == NULL) {
- joinstr = PyBytes_InternFromString("join");
+ joinstr = PyString_InternFromString("join");
}
if (joinstr == NULL || ustr == NULL) {
return NULL;
@@ -227,10 +227,10 @@ static PyObject *
scanstring_str(PyObject *pystr, Py_ssize_t end, char *encoding, int strict)
{
PyObject *rval;
- Py_ssize_t len = PyBytes_GET_SIZE(pystr);
+ Py_ssize_t len = PyString_GET_SIZE(pystr);
Py_ssize_t begin = end - 1;
Py_ssize_t next = begin;
- char *buf = PyBytes_AS_STRING(pystr);
+ char *buf = PyString_AS_STRING(pystr);
PyObject *chunks = PyList_New(0);
if (chunks == NULL) {
goto bail;
@@ -555,7 +555,7 @@ py_scanstring(PyObject* self, PyObject *args)
if (encoding == NULL) {
encoding = DEFAULT_ENCODING;
}
- if (PyBytes_Check(pystr)) {
+ if (PyString_Check(pystr)) {
return scanstring_str(pystr, end, encoding, strict);
}
else if (PyUnicode_Check(pystr)) {
@@ -576,7 +576,7 @@ static PyObject *
py_encode_basestring_ascii(PyObject* self, PyObject *pystr)
{
/* METH_O */
- if (PyBytes_Check(pystr)) {
+ if (PyString_Check(pystr)) {
return ascii_escape_str(pystr);
}
else if (PyUnicode_Check(pystr)) {