summaryrefslogtreecommitdiffstats
path: root/Objects/exceptions.c
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2006-09-20 18:43:13 (GMT)
committerBrett Cannon <bcannon@gmail.com>2006-09-20 18:43:13 (GMT)
commitf6aa86e33ba5b29ff9bd442e80e196746b5d2424 (patch)
treec18f8bff130bd21d2664910a06d303e8282bcb1f /Objects/exceptions.c
parent9adeab7b967069b2722c8a163f3404616b62b8e2 (diff)
downloadcpython-f6aa86e33ba5b29ff9bd442e80e196746b5d2424.zip
cpython-f6aa86e33ba5b29ff9bd442e80e196746b5d2424.tar.gz
cpython-f6aa86e33ba5b29ff9bd442e80e196746b5d2424.tar.bz2
Allow exceptions to be directly sliced again
(e.g., ``BaseException(1,2,3)[0:2]``). Discovered in Python 2.5.0 by Thomas Heller and reported to python-dev. This should be backported to 2.5 .
Diffstat (limited to 'Objects/exceptions.c')
-rw-r--r--Objects/exceptions.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index fda2ab1..bfe28a9 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -190,12 +190,19 @@ BaseException_getitem(PyBaseExceptionObject *self, Py_ssize_t index)
return PySequence_GetItem(self->args, index);
}
+static PyObject *
+BaseException_getslice(PyBaseExceptionObject *self,
+ Py_ssize_t start, Py_ssize_t stop)
+{
+ return PySequence_GetSlice(self->args, start, stop);
+}
+
static PySequenceMethods BaseException_as_sequence = {
0, /* sq_length; */
0, /* sq_concat; */
0, /* sq_repeat; */
(ssizeargfunc)BaseException_getitem, /* sq_item; */
- 0, /* sq_slice; */
+ (ssizessizeargfunc)BaseException_getslice, /* sq_slice; */
0, /* sq_ass_item; */
0, /* sq_ass_slice; */
0, /* sq_contains; */