File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,6 +12,9 @@ What's New in Python 2.6 alpha 2?
1212Core and builtins
1313-----------------
1414
15+ - Issue 2379: Raise a Py3K warning for __getitem__ or __getslice__ on
16+ exception instances.
17+
1518- Issue #2371: Add a Py3k warning when catching an exception that
1619 doesn't derive from BaseException. Issue #2341: Add a Py3k warning
1720 when raising an exception that doesn't derive from BaseException.
Original file line number Diff line number Diff line change @@ -189,13 +189,25 @@ static PyMethodDef BaseException_methods[] = {
189189static PyObject *
190190BaseException_getitem (PyBaseExceptionObject * self , Py_ssize_t index )
191191{
192+ if (Py_Py3kWarningFlag ) {
193+ if (PyErr_Warn (PyExc_DeprecationWarning ,
194+ "In 3.x, __getitem__ is not supported for exception "
195+ "classes, use args attribute" ) == -1 )
196+ return NULL ;
197+ }
192198 return PySequence_GetItem (self -> args , index );
193199}
194200
195201static PyObject *
196202BaseException_getslice (PyBaseExceptionObject * self ,
197203 Py_ssize_t start , Py_ssize_t stop )
198204{
205+ if (Py_Py3kWarningFlag ) {
206+ if (PyErr_Warn (PyExc_DeprecationWarning ,
207+ "In 3.x, __getslice__ is not supported for exception "
208+ "classes, use args attribute" ) == -1 )
209+ return NULL ;
210+ }
199211 return PySequence_GetSlice (self -> args , start , stop );
200212}
201213
You can’t perform that action at this time.
0 commit comments