]> granicus.if.org Git - python/commitdiff
cleanup Ellipsis and NotImplemented strings after we're done
authorBenjamin Peterson <benjamin@python.org>
Fri, 16 Mar 2012 23:45:31 +0000 (18:45 -0500)
committerBenjamin Peterson <benjamin@python.org>
Fri, 16 Mar 2012 23:45:31 +0000 (18:45 -0500)
Modules/_pickle.c

index 9410e528b6c86b379161de91a5906563fa6562e9..5ba559948fb2e7bc967f0b93ca26745ef43eab3f 100644 (file)
@@ -2815,18 +2815,24 @@ static int
 save_ellipsis(PicklerObject *self, PyObject *obj)
 {
     PyObject *str = PyUnicode_FromString("Ellipsis");
+    int res;
     if (str == NULL)
         return -1;
-    return save_global(self, Py_Ellipsis, str);
+    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;
-    return save_global(self, Py_NotImplemented, str);
+    res = save_global(self, Py_NotImplemented, str);
+    Py_DECREF(str);
+    return res;
 }
 
 static int