diff options
author | Guido van Rossum <guido@python.org> | 2003-01-29 17:58:45 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2003-01-29 17:58:45 (GMT) |
commit | 5d9113d8be81596bc93f2b1a37f57e5110d39a77 (patch) | |
tree | f7bdf7fc9aa5afbf967e9e110baea0e4cdd9ffec /Objects/tupleobject.c | |
parent | d3590f937f4493445beeb253e5048771d1663ab7 (diff) | |
download | cpython-5d9113d8be81596bc93f2b1a37f57e5110d39a77.zip cpython-5d9113d8be81596bc93f2b1a37f57e5110d39a77.tar.gz cpython-5d9113d8be81596bc93f2b1a37f57e5110d39a77.tar.bz2 |
Implement appropriate __getnewargs__ for all immutable subclassable builtin
types. The special handling for these can now be removed from save_newobj().
Add some testing for this.
Also add support for setting the 'fast' flag on the Python Pickler class,
which suppresses use of the memo.
Diffstat (limited to 'Objects/tupleobject.c')
-rw-r--r-- | Objects/tupleobject.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index 3a8f072..d6d0aaa 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -587,6 +587,18 @@ tuplesubscript(PyTupleObject* self, PyObject* item) } } +static PyObject * +tuple_getnewargs(PyTupleObject *v) +{ + return Py_BuildValue("(N)", tupleslice(v, 0, v->ob_size)); + +} + +static PyMethodDef tuple_methods[] = { + {"__getnewargs__", (PyCFunction)tuple_getnewargs, METH_NOARGS}, + {NULL, NULL} /* sentinel */ +}; + static PyMappingMethods tuple_as_mapping = { (inquiry)tuplelength, (binaryfunc)tuplesubscript, @@ -625,7 +637,7 @@ PyTypeObject PyTuple_Type = { 0, /* tp_weaklistoffset */ tuple_iter, /* tp_iter */ 0, /* tp_iternext */ - 0, /* tp_methods */ + tuple_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ 0, /* tp_base */ |