Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Lib/test/test_py3kwarn.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,13 @@ def test_nonascii_bytes_literals(self):
with check_py3k_warnings((expected, SyntaxWarning)):
exec "b'\xbd'"

def test_raise_three_components(self):
expected = """the raise clause with three components is not supported in 3.x; \
use 'raise' with a single object"""
with check_py3k_warnings((expected, SyntaxWarning)):
excType, excValue, excTraceback = sys.exc_info()
raise excType, excValue, excTraceback


class TestStdlibRemovals(unittest.TestCase):

Expand Down
6 changes: 6 additions & 0 deletions Python/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -2459,6 +2459,12 @@ ast_for_flow_stmt(struct compiling *c, const node *n)
else if (NCH(ch) == 6) {
expr_ty expr1, expr2, expr3;

if (Py_Py3kWarningFlag &&
!ast_3x_warn(c, n, "the raise clause with three components is not supported in 3.x",
"use 'raise' with a single object")) {
return NULL;
}

expr1 = ast_for_expr(c, CHILD(ch, 1));
if (!expr1)
return NULL;
Expand Down