summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2006-05-30 07:13:29 (GMT)
committerGeorg Brandl <georg@python.org>2006-05-30 07:13:29 (GMT)
commit05f97bffac5ae9ded29c5f845dff5edc99ff1620 (patch)
treea0eb1739480e8ae10b9d7f3032a93d1b94e807f9 /Objects
parentddba473e2639f4db6db51e66851a5c056ba0e18d (diff)
downloadcpython-05f97bffac5ae9ded29c5f845dff5edc99ff1620.zip
cpython-05f97bffac5ae9ded29c5f845dff5edc99ff1620.tar.gz
cpython-05f97bffac5ae9ded29c5f845dff5edc99ff1620.tar.bz2
Add a test case for exception pickling. args is never NULL.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/exceptions.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index 986d211..16ba5e5 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -143,15 +143,8 @@ BaseException_reduce(PyBaseExceptionObject *self)
{
if (self->args && self->dict)
return PyTuple_Pack(3, self->ob_type, self->args, self->dict);
- else if (self->args)
+ else
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;
- }
}
@@ -667,6 +660,7 @@ EnvironmentError_reduce(PyEnvironmentErrorObject *self)
{
PyObject *args = self->args;
PyObject *res = NULL, *tmp;
+
/* self->args is only the first two real arguments if there was a
* file name given to EnvironmentError. */
if (PyTuple_GET_SIZE(args) == 2 && self->filename) {
@@ -683,10 +677,13 @@ EnvironmentError_reduce(PyEnvironmentErrorObject *self)
Py_INCREF(self->filename);
PyTuple_SET_ITEM(args, 2, self->filename);
- } else {
+ } else
Py_INCREF(args);
- }
- res = PyTuple_Pack(3, self->ob_type, args, self->dict);
+
+ if (self->dict)
+ res = PyTuple_Pack(3, self->ob_type, args, self->dict);
+ else
+ res = PyTuple_Pack(2, self->ob_type, args);
Py_DECREF(args);
return res;
}