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.
This commit is contained in:
Gregory P. Smith 2008-06-09 04:58:54 +00:00
parent e98839a1f4
commit dd96db63f6
173 changed files with 2275 additions and 2280 deletions

View file

@ -1199,7 +1199,7 @@ PyAPI_FUNC(PyObject *)
_PyLong_Format(PyObject *aa, int base, int addL, int newstyle)
{
register PyLongObject *a = (PyLongObject *)aa;
PyBytesObject *str;
PyStringObject *str;
Py_ssize_t i, j, sz;
Py_ssize_t size_a;
char *p;
@ -1228,10 +1228,10 @@ _PyLong_Format(PyObject *aa, int base, int addL, int newstyle)
"long is too large to format");
return NULL;
}
str = (PyBytesObject *) PyBytes_FromStringAndSize((char *)0, sz);
str = (PyStringObject *) PyString_FromStringAndSize((char *)0, sz);
if (str == NULL)
return NULL;
p = PyBytes_AS_STRING(str) + sz;
p = PyString_AS_STRING(str) + sz;
*p = '\0';
if (addL)
*--p = 'L';
@ -1257,7 +1257,7 @@ _PyLong_Format(PyObject *aa, int base, int addL, int newstyle)
do {
char cdigit = (char)(accum & (base - 1));
cdigit += (cdigit < 10) ? '0' : 'a'-10;
assert(p > PyBytes_AS_STRING(str));
assert(p > PyString_AS_STRING(str));
*--p = cdigit;
accumbits -= basebits;
accum >>= basebits;
@ -1309,7 +1309,7 @@ _PyLong_Format(PyObject *aa, int base, int addL, int newstyle)
do {
digit nextrem = (digit)(rem / base);
char c = (char)(rem - nextrem * base);
assert(p > PyBytes_AS_STRING(str));
assert(p > PyString_AS_STRING(str));
c += (c < 10) ? '0' : 'a'-10;
*--p = c;
rem = nextrem;
@ -1347,14 +1347,14 @@ _PyLong_Format(PyObject *aa, int base, int addL, int newstyle)
}
if (sign)
*--p = sign;
if (p != PyBytes_AS_STRING(str)) {
char *q = PyBytes_AS_STRING(str);
if (p != PyString_AS_STRING(str)) {
char *q = PyString_AS_STRING(str);
assert(p > q);
do {
} while ((*q++ = *p++) != '\0');
q--;
_PyBytes_Resize((PyObject **)&str,
(Py_ssize_t) (q - PyBytes_AS_STRING(str)));
_PyString_Resize((PyObject **)&str,
(Py_ssize_t) (q - PyString_AS_STRING(str)));
}
return (PyObject *)str;
}
@ -1718,7 +1718,7 @@ digit beyond the first.
onError:
Py_XDECREF(z);
slen = strlen(orig_str) < 200 ? strlen(orig_str) : 200;
strobj = PyBytes_FromStringAndSize(orig_str, slen);
strobj = PyString_FromStringAndSize(orig_str, slen);
if (strobj == NULL)
return NULL;
strrepr = PyObject_Repr(strobj);
@ -1727,7 +1727,7 @@ digit beyond the first.
return NULL;
PyErr_Format(PyExc_ValueError,
"invalid literal for long() with base %d: %s",
base, PyBytes_AS_STRING(strrepr));
base, PyString_AS_STRING(strrepr));
Py_DECREF(strrepr);
return NULL;
}
@ -3331,11 +3331,11 @@ long_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return PyLong_FromLong(0L);
if (base == -909)
return PyNumber_Long(x);
else if (PyBytes_Check(x)) {
else if (PyString_Check(x)) {
/* Since PyLong_FromString doesn't have a length parameter,
* check here for possible NULs in the string. */
char *string = PyBytes_AS_STRING(x);
if (strlen(string) != PyBytes_Size(x)) {
char *string = PyString_AS_STRING(x);
if (strlen(string) != PyString_Size(x)) {
/* create a repr() of the input string,
* just like PyLong_FromString does. */
PyObject *srepr;
@ -3344,11 +3344,11 @@ long_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return NULL;
PyErr_Format(PyExc_ValueError,
"invalid literal for long() with base %d: %s",
base, PyBytes_AS_STRING(srepr));
base, PyString_AS_STRING(srepr));
Py_DECREF(srepr);
return NULL;
}
return PyLong_FromString(PyBytes_AS_STRING(x), NULL, base);
return PyLong_FromString(PyString_AS_STRING(x), NULL, base);
}
#ifdef Py_USING_UNICODE
else if (PyUnicode_Check(x))