From: Georg Brandl Date: Tue, 30 May 2006 07:04:55 +0000 (+0000) Subject: Restore exception pickle support. #1497319. X-Git-Tag: v2.5b1~339 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ddba473e2639f4db6db51e66851a5c056ba0e18d;p=python Restore exception pickle support. #1497319. --- diff --git a/Objects/exceptions.c b/Objects/exceptions.c index 44c8fd65a5..986d2110c6 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -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; + } }