Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit48f8eb8

Browse files
14: Warn for raise with three compnents r=ltratt a=nanjekyejoannahThis makes sense at the AST hence isolated from the [other exception PR](softdevteam#12)Co-authored-by: Joannah Nanjekye <jnanjekye@python.org>
2 parents4b248a8 +99183ef commit48f8eb8

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

‎Lib/test/test_py3kwarn.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,13 @@ def test_nonascii_bytes_literals(self):
369369
withcheck_py3k_warnings((expected,SyntaxWarning)):
370370
exec"b'\xbd'"
371371

372+
deftest_raise_three_components(self):
373+
expected="""the raise clause with three components is not supported in 3.x;\
374+
use 'raise' with a single object"""
375+
withcheck_py3k_warnings((expected,SyntaxWarning)):
376+
excType,excValue,excTraceback=sys.exc_info()
377+
raiseexcType,excValue,excTraceback
378+
372379

373380
classTestStdlibRemovals(unittest.TestCase):
374381

‎Python/ast.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2459,6 +2459,12 @@ ast_for_flow_stmt(struct compiling *c, const node *n)
24592459
elseif (NCH(ch)==6) {
24602460
expr_tyexpr1,expr2,expr3;
24612461

2462+
if (Py_Py3kWarningFlag&&
2463+
!ast_3x_warn(c,n,"the raise clause with three components is not supported in 3.x",
2464+
"use 'raise' with a single object")) {
2465+
returnNULL;
2466+
}
2467+
24622468
expr1=ast_for_expr(c,CHILD(ch,1));
24632469
if (!expr1)
24642470
returnNULL;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp