Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
6d91be37
Commit
6d91be37
authored
Mar 18, 2008
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Issue 2379: Raise a Py3K warning for __getitem__ or __getslice__ on
exception instances.
parent
0bfc8969
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
0 deletions
+15
-0
Misc/NEWS
Misc/NEWS
+3
-0
Objects/exceptions.c
Objects/exceptions.c
+12
-0
No files found.
Misc/NEWS
View file @
6d91be37
...
...
@@ -12,6 +12,9 @@ What's New in Python 2.6 alpha 2?
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.
...
...
Objects/exceptions.c
View file @
6d91be37
...
...
@@ -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
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment