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.
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 @@
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 @@
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 */