mirror of
https://github.com/python/cpython.git
synced 2025-07-30 06:34:15 +00:00
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 .
This commit is contained in:
parent
9adeab7b96
commit
f6aa86e33b
2 changed files with 10 additions and 1 deletions
|
@ -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; */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue