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
04edb528
Commit
04edb528
authored
Mar 18, 2008
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Issue #2371: Add a Py3k warning when catching an exception that
doesn't derive from BaseException.
parent
0bb79508
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
0 deletions
+31
-0
Misc/ACKS
Misc/ACKS
+1
-0
Misc/NEWS
Misc/NEWS
+3
-0
Python/ceval.c
Python/ceval.c
+27
-0
No files found.
Misc/ACKS
View file @
04edb528
...
@@ -360,6 +360,7 @@ Magnus Kessler
...
@@ -360,6 +360,7 @@ Magnus Kessler
Lawrence Kesteloot
Lawrence Kesteloot
Vivek Khera
Vivek Khera
Mads Kiilerich
Mads Kiilerich
Taek Joo Kim
Steve Kirsch
Steve Kirsch
Ron Klatchko
Ron Klatchko
Bastian Kleineidam
Bastian Kleineidam
...
...
Misc/NEWS
View file @
04edb528
...
@@ -12,6 +12,9 @@ What's New in Python 2.6 alpha 2?
...
@@ -12,6 +12,9 @@ What's New in Python 2.6 alpha 2?
Core and builtins
Core and builtins
-----------------
-----------------
- Issue #2371: Add a Py3k warning when catching an exception that
doesn't derive from BaseException.
- Issue #2321: use pymalloc for unicode object string data to reduce
- Issue #2321: use pymalloc for unicode object string data to reduce
memory usage in some circumstances.
memory usage in some circumstances.
...
...
Python/ceval.c
View file @
04edb528
...
@@ -4042,6 +4042,13 @@ assign_slice(PyObject *u, PyObject *v, PyObject *w, PyObject *x)
...
@@ -4042,6 +4042,13 @@ assign_slice(PyObject *u, PyObject *v, PyObject *w, PyObject *x)
}
}
}
}
#define Py3kExceptionClass_Check(x) \
(PyType_Check((x)) && \
PyType_FastSubclass((PyTypeObject*)(x), Py_TPFLAGS_BASE_EXC_SUBCLASS))
#define CANNOT_CATCH_MSG "catching classes that don't inherit from " \
"BaseException is not allowed in 3.x."
static
PyObject
*
static
PyObject
*
cmp_outcome
(
int
op
,
register
PyObject
*
v
,
register
PyObject
*
w
)
cmp_outcome
(
int
op
,
register
PyObject
*
v
,
register
PyObject
*
w
)
{
{
...
@@ -4079,6 +4086,16 @@ cmp_outcome(int op, register PyObject *v, register PyObject *w)
...
@@ -4079,6 +4086,16 @@ cmp_outcome(int op, register PyObject *v, register PyObject *w)
if
(
ret_val
==
-
1
)
if
(
ret_val
==
-
1
)
return
NULL
;
return
NULL
;
}
}
if
(
Py_Py3kWarningFlag
&&
!
Py3kExceptionClass_Check
(
exc
))
{
int
ret_val
;
ret_val
=
PyErr_WarnEx
(
PyExc_DeprecationWarning
,
CANNOT_CATCH_MSG
,
1
);
if
(
ret_val
==
-
1
)
return
NULL
;
}
}
}
}
}
else
{
else
{
...
@@ -4091,6 +4108,16 @@ cmp_outcome(int op, register PyObject *v, register PyObject *w)
...
@@ -4091,6 +4108,16 @@ cmp_outcome(int op, register PyObject *v, register PyObject *w)
if
(
ret_val
==
-
1
)
if
(
ret_val
==
-
1
)
return
NULL
;
return
NULL
;
}
}
if
(
Py_Py3kWarningFlag
&&
!
Py3kExceptionClass_Check
(
w
))
{
int
ret_val
;
ret_val
=
PyErr_WarnEx
(
PyExc_DeprecationWarning
,
CANNOT_CATCH_MSG
,
1
);
if
(
ret_val
==
-
1
)
return
NULL
;
}
}
}
res
=
PyErr_GivenExceptionMatches
(
v
,
w
);
res
=
PyErr_GivenExceptionMatches
(
v
,
w
);
break
;
break
;
...
...
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