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

@ -3171,30 +3171,6 @@ save_global(PicklerObject *self, PyObject *obj, PyObject *name)
return status;
}
static int
save_ellipsis(PicklerObject *self, PyObject *obj)
{
PyObject *str = PyUnicode_FromString("Ellipsis");
int res;
if (str == NULL)
return -1;
res = save_global(self, Py_Ellipsis, str);
Py_DECREF(str);
return res;
}
static int
save_notimplemented(PicklerObject *self, PyObject *obj)
{
PyObject *str = PyUnicode_FromString("NotImplemented");
int res;
if (str == NULL)
return -1;
res = save_global(self, Py_NotImplemented, str);
Py_DECREF(str);
return res;
}
static int
save_pers(PicklerObject *self, PyObject *obj, PyObject *func)
{
@ -3552,14 +3528,6 @@ save(PicklerObject *self, PyObject *obj, int pers_save)
status = save_none(self, obj);
goto done;
}
else if (obj == Py_Ellipsis) {
status = save_ellipsis(self, obj);
goto done;
}
else if (obj == Py_NotImplemented) {
status = save_notimplemented(self, obj);
goto done;
}
else if (obj == Py_False || obj == Py_True) {
status = save_bool(self, obj);
goto done;