summaryrefslogtreecommitdiff
path: root/Objects/exceptions.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2008-03-18 04:42:22 +0000
committerGuido van Rossum <guido@python.org>2008-03-18 04:42:22 +0000
commit17305272f2d843aa14f78322a7a2b0906451a486 (patch)
tree0cf127137fff6980f009cea1ecc9c8928d77f531 /Objects/exceptions.c
parenta8e48c512e0678cb1bbb0d6446a64bc51e5f1ab9 (diff)
downloadcpython-17305272f2d843aa14f78322a7a2b0906451a486.tar.gz
- Issue 2379: Raise a Py3K warning for __getitem__ or __getslice__ on
exception instances.
Diffstat (limited to 'Objects/exceptions.c')
-rw-r--r--Objects/exceptions.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index b1d5d0b6d5..aa9f516921 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);
}