diff options
author | Guido van Rossum <guido@python.org> | 2007-04-11 05:40:58 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-04-11 05:40:58 (GMT) |
commit | 0dd32e246cd232012d07926ae312205decb74b61 (patch) | |
tree | baf67ba755cabaf97a021dd4823087303e7ee5e3 /Objects/bytesobject.c | |
parent | 0ad0812edb3b4023f3e410243c007fba3f84a9ff (diff) | |
download | cpython-0dd32e246cd232012d07926ae312205decb74b61.zip cpython-0dd32e246cd232012d07926ae312205decb74b61.tar.gz cpython-0dd32e246cd232012d07926ae312205decb74b61.tar.bz2 |
Real pickling for bytes.
Restore complex pickling.
Use cPickle in io.py.
Diffstat (limited to 'Objects/bytesobject.c')
-rw-r--r-- | Objects/bytesobject.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index d985fc7..be3da7a 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -2598,6 +2598,17 @@ bytes_fromhex(PyObject *cls, PyObject *args) return NULL; } +PyDoc_STRVAR(reduce_doc, "Return state information for pickling."); + +static PyObject * +bytes_reduce(PyBytesObject *self) +{ + return Py_BuildValue("(O(s#))", + self->ob_type, + self->ob_bytes == NULL ? "" : self->ob_bytes, + self->ob_size); +} + static PySequenceMethods bytes_as_sequence = { (lenfunc)bytes_length, /* sq_length */ (binaryfunc)bytes_concat, /* sq_concat */ @@ -2650,8 +2661,10 @@ bytes_methods[] = { {"remove", (PyCFunction)bytes_remove, METH_O, remove__doc__}, {"decode", (PyCFunction)bytes_decode, METH_VARARGS, decode_doc}, {"__alloc__", (PyCFunction)bytes_alloc, METH_NOARGS, alloc_doc}, - {"fromhex", (PyCFunction)bytes_fromhex, METH_VARARGS|METH_CLASS, fromhex_doc}, + {"fromhex", (PyCFunction)bytes_fromhex, METH_VARARGS|METH_CLASS, + fromhex_doc}, {"join", (PyCFunction)bytes_join, METH_O|METH_CLASS, join_doc}, + {"__reduce__", (PyCFunction)bytes_reduce, METH_NOARGS, reduce_doc}, {NULL} }; |