diff options
author | Guido van Rossum <guido@python.org> | 2008-03-18 04:42:22 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2008-03-18 04:42:22 (GMT) |
commit | 6d91be37586ba93cb7c5fa6d5da15cf5b9a19892 (patch) | |
tree | 5847d95b3dbae4d914a47bfba6a750b26ea3d75b /Objects | |
parent | 0bfc896979c94b02fe34cbad246b14b9d82ec40a (diff) | |
download | cpython-6d91be37586ba93cb7c5fa6d5da15cf5b9a19892.zip cpython-6d91be37586ba93cb7c5fa6d5da15cf5b9a19892.tar.gz cpython-6d91be37586ba93cb7c5fa6d5da15cf5b9a19892.tar.bz2 |
- Issue 2379: Raise a Py3K warning for __getitem__ or __getslice__ on
exception instances.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/exceptions.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c index b1d5d0b..aa9f516 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -189,6 +189,12 @@ static PyMethodDef BaseException_methods[] = { static PyObject * BaseException_getitem(PyBaseExceptionObject *self, Py_ssize_t index) { + if (Py_Py3kWarningFlag) { + if (PyErr_Warn(PyExc_DeprecationWarning, + "In 3.x, __getitem__ is not supported for exception " + "classes, use args attribute") == -1) + return NULL; + } return PySequence_GetItem(self->args, index); } @@ -196,6 +202,12 @@ static PyObject * BaseException_getslice(PyBaseExceptionObject *self, Py_ssize_t start, Py_ssize_t stop) { + if (Py_Py3kWarningFlag) { + if (PyErr_Warn(PyExc_DeprecationWarning, + "In 3.x, __getslice__ is not supported for exception " + "classes, use args attribute") == -1) + return NULL; + } return PySequence_GetSlice(self->args, start, stop); } |