mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Added better pickling support to xrange objects.
Cleaned up the unit test.
This commit is contained in:
parent
1f2f61a78f
commit
602d8db2bc
2 changed files with 13 additions and 12 deletions
|
@ -131,9 +131,9 @@ range_repr(rangeobject *r)
|
|||
|
||||
/* Pickling support */
|
||||
static PyObject *
|
||||
range_getnewargs(rangeobject *r)
|
||||
range_reduce(rangeobject *r, PyObject *args)
|
||||
{
|
||||
return Py_BuildValue("(iii)",
|
||||
return Py_BuildValue("(O(iii))", Py_TYPE(r),
|
||||
r->start,
|
||||
r->start + r->len * r->step,
|
||||
r->step);
|
||||
|
@ -155,7 +155,7 @@ PyDoc_STRVAR(reverse_doc,
|
|||
|
||||
static PyMethodDef range_methods[] = {
|
||||
{"__reversed__", (PyCFunction)range_reverse, METH_NOARGS, reverse_doc},
|
||||
{"__getnewargs__", (PyCFunction)range_getnewargs, METH_NOARGS},
|
||||
{"__reduce__", (PyCFunction)range_reduce, METH_VARARGS},
|
||||
{NULL, NULL} /* sentinel */
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue