[Python-checkins] r61489 - in python/trunk: Misc/NEWS Objects/exceptions.c
guido.van.rossum
python-checkins at python.org
Tue Mar 18 05:42:22 CET 2008
Author: guido.van.rossum
Date: Tue Mar 18 05:42:22 2008
New Revision: 61489
Modified:
python/trunk/Misc/NEWS
python/trunk/Objects/exceptions.c
Log:
- Issue 2379: Raise a Py3K warning for __getitem__ or __getslice__ on
exception instances.
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Tue Mar 18 05:42:22 2008
@@ -12,6 +12,9 @@
Core and builtins
-----------------
+- Issue 2379: Raise a Py3K warning for __getitem__ or __getslice__ on
+ exception instances.
+
- Issue #2371: Add a Py3k warning when catching an exception that
doesn't derive from BaseException. Issue #2341: Add a Py3k warning
when raising an exception that doesn't derive from BaseException.
Modified: python/trunk/Objects/exceptions.c
==============================================================================
--- python/trunk/Objects/exceptions.c (original)
+++ python/trunk/Objects/exceptions.c Tue Mar 18 05:42:22 2008
@@ -189,6 +189,12 @@
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 @@
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);
}
More information about the Python-checkins
mailing list