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 /Objects/longobject.c | |
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 'Objects/longobject.c')
-rw-r--r-- | Objects/longobject.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/Objects/longobject.c b/Objects/longobject.c index c9d138b..c65d0c0 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -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)) |