diff options
author | Łukasz Langa <lukasz@langa.pl> | 2012-03-12 18:46:12 (GMT) |
---|---|---|
committer | Łukasz Langa <lukasz@langa.pl> | 2012-03-12 18:46:12 (GMT) |
commit | f3078fbee2b6555f0f5b1819a231f4b7d8bdf6b5 (patch) | |
tree | e1948498519d1e9e3d5cb91493ec9d6928268425 /Modules | |
parent | e976fc74647f679519edde2a1e0b73ff711e079b (diff) | |
download | cpython-f3078fbee2b6555f0f5b1819a231f4b7d8bdf6b5.zip cpython-f3078fbee2b6555f0f5b1819a231f4b7d8bdf6b5.tar.gz cpython-f3078fbee2b6555f0f5b1819a231f4b7d8bdf6b5.tar.bz2 |
Fixes #13842: cannot pickle Ellipsis or NotImplemented.
Thanks for James Sanders for the bug report and the patch.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_pickle.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Modules/_pickle.c b/Modules/_pickle.c index 2dc3a41..4212e7a 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -2812,6 +2812,19 @@ save_global(PicklerObject *self, PyObject *obj, PyObject *name) } static int +save_ellipsis(PicklerObject *self, PyObject *obj) +{ + return save_global(self, Py_Ellipsis, PyUnicode_FromString("Ellipsis")); +} + +static int +save_notimplemented(PicklerObject *self, PyObject *obj) +{ + return save_global(self, Py_NotImplemented, + PyUnicode_FromString("NotImplemented")); +} + +static int save_pers(PicklerObject *self, PyObject *obj, PyObject *func) { PyObject *pid = NULL; @@ -3114,6 +3127,14 @@ 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; |