mirror of
https://github.com/python/cpython.git
synced 2025-07-29 14:15:07 +00:00
Restore exception pickle support. #1497319.
This commit is contained in:
parent
33f4a6a31a
commit
ddba473e26
1 changed files with 11 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue