mirror of
https://github.com/python/cpython.git
synced 2025-09-17 22:20:23 +00:00
Issue 2582: Fix pickling of xrange objects.
This commit is contained in:
parent
5c4d3d0e4c
commit
1f2f61a78f
2 changed files with 21 additions and 0 deletions
|
@ -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 */
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue