]> granicus.if.org Git - python/commitdiff
Restore exception pickle support. #1497319.
authorGeorg Brandl <georg@python.org>
Tue, 30 May 2006 07:04:55 +0000 (07:04 +0000)
committerGeorg Brandl <georg@python.org>
Tue, 30 May 2006 07:04:55 +0000 (07:04 +0000)
Objects/exceptions.c

index 44c8fd65a5c3136a7b4ffa24f4892bf95c12989c..986d2110c67171fd4e9aa3934ea730449d8f2313 100644 (file)
@@ -141,7 +141,17 @@ BaseException_repr(PyBaseExceptionObject *self)
 static PyObject *
 BaseException_reduce(PyBaseExceptionObject *self)
 {
-    return PyTuple_Pack(3, self->ob_type, self->args, self->dict);
+    if (self->args && self->dict)
+        return PyTuple_Pack(3, self->ob_type, self->args, self->dict);
+    else if (self->args)
+        return PyTuple_Pack(2, self->ob_type, self->args);
+    else {
+        PyObject *res, *tup = PyTuple_New(0);
+        if (!tup) return NULL;
+        res = PyTuple_Pack(2, self->ob_type, tup);
+        Py_DECREF(tup);
+        return res;
+    }
 }