summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2013-02-27 13:57:09 (GMT)
committerR David Murray <rdmurray@bitdance.com>2013-02-27 13:57:09 (GMT)
commit1cb0cb2fcdc83a6caa871104a622d1217ca034a3 (patch)
tree30adf3f3b7af0f167b4fa7d618b0fcdddf6e605b /Objects
parent5f794098898b49650b2ef6a0c4f48aa0d03b0298 (diff)
downloadcpython-1cb0cb2fcdc83a6caa871104a622d1217ca034a3.zip
cpython-1cb0cb2fcdc83a6caa871104a622d1217ca034a3.tar.gz
cpython-1cb0cb2fcdc83a6caa871104a622d1217ca034a3.tar.bz2
#17296: backport fix for issue 1692335, naive exception pickling.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/exceptions.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index 9daa12a..a4e90fc 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -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;
}