diff options
author | Alexandre Vassalotti <alexandre@peadrop.com> | 2008-06-10 03:34:53 (GMT) |
---|---|---|
committer | Alexandre Vassalotti <alexandre@peadrop.com> | 2008-06-10 03:34:53 (GMT) |
commit | 1f2f61a78f80933a3e703df1ab08f14e70ea87d5 (patch) | |
tree | 16564a14337a5308204cb7bcffba685bb8e76b7b /Objects/rangeobject.c | |
parent | 5c4d3d0e4c6b533dbfbab36ad8034010fe90cf69 (diff) | |
download | cpython-1f2f61a78f80933a3e703df1ab08f14e70ea87d5.zip cpython-1f2f61a78f80933a3e703df1ab08f14e70ea87d5.tar.gz cpython-1f2f61a78f80933a3e703df1ab08f14e70ea87d5.tar.bz2 |
Issue 2582: Fix pickling of xrange objects.
Diffstat (limited to 'Objects/rangeobject.c')
-rw-r--r-- | Objects/rangeobject.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c index da4356b..bfc038e 100644 --- a/Objects/rangeobject.c +++ b/Objects/rangeobject.c @@ -129,6 +129,16 @@ range_repr(rangeobject *r) return rtn; } +/* Pickling support */ +static PyObject * +range_getnewargs(rangeobject *r) +{ + return Py_BuildValue("(iii)", + r->start, + r->start + r->len * r->step, + r->step); +} + static PySequenceMethods range_as_sequence = { (lenfunc)range_length, /* sq_length */ 0, /* sq_concat */ @@ -145,6 +155,7 @@ PyDoc_STRVAR(reverse_doc, static PyMethodDef range_methods[] = { {"__reversed__", (PyCFunction)range_reverse, METH_NOARGS, reverse_doc}, + {"__getnewargs__", (PyCFunction)range_getnewargs, METH_NOARGS}, {NULL, NULL} /* sentinel */ }; |