#17296: backport fix for issue 1692335, naive exception pickling.

This commit is contained in:
R David Murray 2013-02-27 08:57:09 -05:00
parent 5f79409889
commit 1cb0cb2fcd
3 changed files with 28 additions and 2 deletions

View file

@ -29,6 +29,12 @@ BaseException_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
self->dict = NULL;
self->traceback = self->cause = self->context = NULL;
if (args) {
self->args = args;
Py_INCREF(args);
return (PyObject *)self;
}
self->args = PyTuple_New(0);
if (!self->args) {
Py_DECREF(self);
@ -41,12 +47,15 @@ BaseException_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
static int
BaseException_init(PyBaseExceptionObject *self, PyObject *args, PyObject *kwds)
{
PyObject *tmp;
if (!_PyArg_NoKeywords(Py_TYPE(self)->tp_name, kwds))
return -1;
Py_DECREF(self->args);
tmp = self->args;
self->args = args;
Py_INCREF(self->args);
Py_XDECREF(tmp);
return 0;
}