Make Ellipsis and NotImplemented picklable through the reduce protocol.

This commit is contained in:
Alexandre Vassalotti 2013-11-24 02:53:45 -08:00
parent 4c05d3bc56
commit c49477b184
4 changed files with 24 additions and 42 deletions

View file

@ -1464,6 +1464,17 @@ NotImplemented_repr(PyObject *op)
return PyUnicode_FromString("NotImplemented");
}
static PyObject *
NotImplemented_reduce(PyObject *op)
{
return PyUnicode_FromString("NotImplemented");
}
static PyMethodDef notimplemented_methods[] = {
{"__reduce__", (PyCFunction)NotImplemented_reduce, METH_NOARGS, NULL},
{NULL, NULL}
};
static PyObject *
notimplemented_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
@ -1511,7 +1522,7 @@ static PyTypeObject PyNotImplemented_Type = {
0, /*tp_weaklistoffset */
0, /*tp_iter */
0, /*tp_iternext */
0, /*tp_methods */
notimplemented_methods, /*tp_methods */
0, /*tp_members */
0, /*tp_getset */
0, /*tp_base */