summaryrefslogtreecommitdiffstats
path: root/Objects/intobject.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2003-01-29 17:58:45 (GMT)
committerGuido van Rossum <guido@python.org>2003-01-29 17:58:45 (GMT)
commit5d9113d8be81596bc93f2b1a37f57e5110d39a77 (patch)
treef7bdf7fc9aa5afbf967e9e110baea0e4cdd9ffec /Objects/intobject.c
parentd3590f937f4493445beeb253e5048771d1663ab7 (diff)
downloadcpython-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/intobject.c')
-rw-r--r--Objects/intobject.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/Objects/intobject.c b/Objects/intobject.c
index 805f3b7..915ef21 100644
--- a/Objects/intobject.c
+++ b/Objects/intobject.c
@@ -850,6 +850,17 @@ int_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return new;
}
+static PyObject *
+int_getnewargs(PyIntObject *v)
+{
+ return Py_BuildValue("(l)", v->ob_ival);
+}
+
+static PyMethodDef int_methods[] = {
+ {"__getnewargs__", (PyCFunction)int_getnewargs, METH_NOARGS},
+ {NULL, NULL} /* sentinel */
+};
+
PyDoc_STRVAR(int_doc,
"int(x[, base]) -> integer\n\
\n\
@@ -931,7 +942,7 @@ PyTypeObject PyInt_Type = {
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
- 0, /* tp_methods */
+ int_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */