mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
bpo-36068: Make _tuplegetter objects serializable (GH-11981)
This commit is contained in:
parent
407c734326
commit
f36f89257b
3 changed files with 23 additions and 3 deletions
|
@ -2440,12 +2440,23 @@ tuplegetter_dealloc(_tuplegetterobject *self)
|
|||
Py_TYPE(self)->tp_free((PyObject*)self);
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
tuplegetter_reduce(_tuplegetterobject *self)
|
||||
{
|
||||
return Py_BuildValue("(O(nO))", (PyObject*) Py_TYPE(self), self->index, self->doc);
|
||||
}
|
||||
|
||||
|
||||
static PyMemberDef tuplegetter_members[] = {
|
||||
{"__doc__", T_OBJECT, offsetof(_tuplegetterobject, doc), 0},
|
||||
{0}
|
||||
};
|
||||
|
||||
static PyMethodDef tuplegetter_methods[] = {
|
||||
{"__reduce__", (PyCFunction) tuplegetter_reduce, METH_NOARGS, NULL},
|
||||
{NULL},
|
||||
};
|
||||
|
||||
static PyTypeObject tuplegetter_type = {
|
||||
PyVarObject_HEAD_INIT(NULL, 0)
|
||||
"_collections._tuplegetter", /* tp_name */
|
||||
|
@ -2475,7 +2486,7 @@ static PyTypeObject tuplegetter_type = {
|
|||
0, /* tp_weaklistoffset */
|
||||
0, /* tp_iter */
|
||||
0, /* tp_iternext */
|
||||
0, /* tp_methods */
|
||||
tuplegetter_methods, /* tp_methods */
|
||||
tuplegetter_members, /* tp_members */
|
||||
0, /* tp_getset */
|
||||
0, /* tp_base */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue