summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorAlexandre Vassalotti <alexandre@peadrop.com>2013-12-01 00:21:20 (GMT)
committerAlexandre Vassalotti <alexandre@peadrop.com>2013-12-01 00:21:20 (GMT)
commit3c23e7a5dcbc1972bd9e26dc26e61d856abb51f1 (patch)
tree600903588902508759b5ad8e3cbeb9d4b8329c1c /Modules
parent9204af42cc271690f57a4bc0d2af53201a796b51 (diff)
parent19b6fa6ebb887e498437b4ae87d6e70b92b4742b (diff)
downloadcpython-3c23e7a5dcbc1972bd9e26dc26e61d856abb51f1.zip
cpython-3c23e7a5dcbc1972bd9e26dc26e61d856abb51f1.tar.gz
cpython-3c23e7a5dcbc1972bd9e26dc26e61d856abb51f1.tar.bz2
Issue #6477: Merge with 3.3.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_pickle.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index a83687b..6445238 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -3288,6 +3288,36 @@ save_global(PicklerObject *self, PyObject *obj, PyObject *name)
}
static int
+save_singleton_type(PicklerObject *self, PyObject *obj, PyObject *singleton)
+{
+ PyObject *reduce_value;
+ int status;
+
+ reduce_value = Py_BuildValue("O(O)", &PyType_Type, singleton);
+ if (reduce_value == NULL) {
+ return -1;
+ }
+ status = save_reduce(self, reduce_value, obj);
+ Py_DECREF(reduce_value);
+ return status;
+}
+
+static int
+save_type(PicklerObject *self, PyObject *obj)
+{
+ if (obj == (PyObject *)&PyNone_Type) {
+ return save_singleton_type(self, obj, Py_None);
+ }
+ else if (obj == (PyObject *)&PyEllipsis_Type) {
+ return save_singleton_type(self, obj, Py_Ellipsis);
+ }
+ else if (obj == (PyObject *)&PyNotImplemented_Type) {
+ return save_singleton_type(self, obj, Py_NotImplemented);
+ }
+ return save_global(self, obj, NULL);
+}
+
+static int
save_pers(PicklerObject *self, PyObject *obj, PyObject *func)
{
PyObject *pid = NULL;
@@ -3696,7 +3726,7 @@ save(PicklerObject *self, PyObject *obj, int pers_save)
goto done;
}
else if (type == &PyType_Type) {
- status = save_global(self, obj, NULL);
+ status = save_type(self, obj);
goto done;
}
else if (type == &PyFunction_Type) {