mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
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.
This commit is contained in:
parent
d3590f937f
commit
5d9113d8be
10 changed files with 133 additions and 19 deletions
|
@ -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 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue