Mercurial > cpython-lru_cache-weakref
diff Python/marshal.c @ 47527:52294af4b663 legacy-trunk
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.
| author | Gregory P. Smith <greg@mad-scientist.com> |
|---|---|
| date | Mon, 09 Jun 2008 04:58:54 +0000 |
| parents | 4fe192d48960 |
| children | 4650eefb5838 |
line wrap: on
line diff
--- a/Python/marshal.c Mon Jun 09 01:28:30 2008 +0000 +++ b/Python/marshal.c Mon Jun 09 04:58:54 2008 +0000 @@ -64,18 +64,18 @@ Py_ssize_t size, newsize; if (p->str == NULL) return; /* An error already occurred */ - size = PyBytes_Size(p->str); + size = PyString_Size(p->str); newsize = size + size + 1024; if (newsize > 32*1024*1024) { newsize = size + 1024*1024; } - if (_PyBytes_Resize(&p->str, newsize) != 0) { + if (_PyString_Resize(&p->str, newsize) != 0) { p->ptr = p->end = NULL; } else { - p->ptr = PyBytes_AS_STRING((PyBytesObject *)p->str) + size; + p->ptr = PyString_AS_STRING((PyStringObject *)p->str) + size; p->end = - PyBytes_AS_STRING((PyBytesObject *)p->str) + newsize; + PyString_AS_STRING((PyStringObject *)p->str) + newsize; *p->ptr++ = Py_SAFE_DOWNCAST(c, int, char); } } @@ -239,8 +239,8 @@ } } #endif - else if (PyBytes_CheckExact(v)) { - if (p->strings && PyBytes_CHECK_INTERNED(v)) { + else if (PyString_CheckExact(v)) { + if (p->strings && PyString_CHECK_INTERNED(v)) { PyObject *o = PyDict_GetItem(p->strings, v); if (o) { long w = PyInt_AsLong(o); @@ -265,7 +265,7 @@ else { w_byte(TYPE_STRING, p); } - n = PyBytes_GET_SIZE(v); + n = PyString_GET_SIZE(v); if (n > INT_MAX) { /* huge strings are not supported */ p->depth--; @@ -273,7 +273,7 @@ return; } w_long((long)n, p); - w_string(PyBytes_AS_STRING(v), (int)n, p); + w_string(PyString_AS_STRING(v), (int)n, p); } #ifdef Py_USING_UNICODE else if (PyUnicode_CheckExact(v)) { @@ -285,14 +285,14 @@ return; } w_byte(TYPE_UNICODE, p); - n = PyBytes_GET_SIZE(utf8); + n = PyString_GET_SIZE(utf8); if (n > INT_MAX) { p->depth--; p->error = 1; return; } w_long((long)n, p); - w_string(PyBytes_AS_STRING(utf8), (int)n, p); + w_string(PyString_AS_STRING(utf8), (int)n, p); Py_DECREF(utf8); } #endif @@ -713,12 +713,12 @@ retval = NULL; break; } - v = PyBytes_FromStringAndSize((char *)NULL, n); + v = PyString_FromStringAndSize((char *)NULL, n); if (v == NULL) { retval = NULL; break; } - if (r_string(PyBytes_AS_STRING(v), (int)n, p) != n) { + if (r_string(PyString_AS_STRING(v), (int)n, p) != n) { Py_DECREF(v); PyErr_SetString(PyExc_EOFError, "EOF read where object expected"); @@ -726,7 +726,7 @@ break; } if (type == TYPE_INTERNED) { - PyBytes_InternInPlace(&v); + PyString_InternInPlace(&v); if (PyList_Append(p->strings, v) < 0) { retval = NULL; break; @@ -1113,11 +1113,11 @@ { WFILE wf; wf.fp = NULL; - wf.str = PyBytes_FromStringAndSize((char *)NULL, 50); + wf.str = PyString_FromStringAndSize((char *)NULL, 50); if (wf.str == NULL) return NULL; - wf.ptr = PyBytes_AS_STRING((PyBytesObject *)wf.str); - wf.end = wf.ptr + PyBytes_Size(wf.str); + wf.ptr = PyString_AS_STRING((PyStringObject *)wf.str); + wf.end = wf.ptr + PyString_Size(wf.str); wf.error = 0; wf.depth = 0; wf.version = version; @@ -1125,14 +1125,14 @@ w_object(x, &wf); Py_XDECREF(wf.strings); if (wf.str != NULL) { - char *base = PyBytes_AS_STRING((PyBytesObject *)wf.str); + char *base = PyString_AS_STRING((PyStringObject *)wf.str); if (wf.ptr - base > PY_SSIZE_T_MAX) { Py_DECREF(wf.str); PyErr_SetString(PyExc_OverflowError, "too much marshall data for a string"); return NULL; } - _PyBytes_Resize(&wf.str, (Py_ssize_t)(wf.ptr - base)); + _PyString_Resize(&wf.str, (Py_ssize_t)(wf.ptr - base)); } if (wf.error) { Py_XDECREF(wf.str);
