diff options
author | Alexandre Vassalotti <alexandre@peadrop.com> | 2008-06-10 04:03:04 (GMT) |
---|---|---|
committer | Alexandre Vassalotti <alexandre@peadrop.com> | 2008-06-10 04:03:04 (GMT) |
commit | 7505607ae764d2095f15fcfb1a0f89843231ba7e (patch) | |
tree | c90ef9c1896e05447590b2fb1213fdf6e4aaf0d6 /Objects/rangeobject.c | |
parent | 1c9a2d96ec511e89b72db9d6c883f8266166f656 (diff) | |
download | cpython-7505607ae764d2095f15fcfb1a0f89843231ba7e.zip cpython-7505607ae764d2095f15fcfb1a0f89843231ba7e.tar.gz cpython-7505607ae764d2095f15fcfb1a0f89843231ba7e.tar.bz2 |
Issue 2582: Fix pickling of range objects.
Diffstat (limited to 'Objects/rangeobject.c')
-rw-r--r-- | Objects/rangeobject.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c index cd5a804..f9a9cc9 100644 --- a/Objects/rangeobject.c +++ b/Objects/rangeobject.c @@ -252,6 +252,14 @@ range_repr(rangeobject *r) r->start, r->stop, r->step); } +/* Pickling support */ +static PyObject * +range_reduce(rangeobject *r, PyObject *args) +{ + return Py_BuildValue("(O(OOO))", Py_TYPE(r), + r->start, r->stop, r->step); +} + static PySequenceMethods range_as_sequence = { (lenfunc)range_length, /* sq_length */ 0, /* sq_concat */ @@ -269,6 +277,7 @@ PyDoc_STRVAR(reverse_doc, static PyMethodDef range_methods[] = { {"__reversed__", (PyCFunction)range_reverse, METH_NOARGS, reverse_doc}, + {"__reduce__", (PyCFunction)range_reduce, METH_VARARGS}, {NULL, NULL} /* sentinel */ }; |