File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -235,6 +235,12 @@ def test_try_stmt(self):
235235 self .check_suite ("try: pass\n except: pass\n else: pass\n "
236236 "finally: pass\n " )
237237
238+ def test_except_clause (self ):
239+ self .check_suite ("try: pass\n except: pass\n " )
240+ self .check_suite ("try: pass\n except A: pass\n " )
241+ self .check_suite ("try: pass\n except A, e: pass\n " )
242+ self .check_suite ("try: pass\n except A as e: pass\n " )
243+
238244 def test_position (self ):
239245 # An absolutely minimal test of position information. Better
240246 # tests would be a big project.
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ Library
2020- Issue #9075: In the ssl module, remove the setting of a ``debug`` flag
2121 on an OpenSSL structure.
2222
23+ - Issue #9125: Add recognition of 'except ... as ...' syntax to parser module.
2324
2425What's New in Python 2.7 release candidate 2?
2526=============================================
Original file line number Diff line number Diff line change @@ -2126,10 +2126,13 @@ validate_except_clause(node *tree)
21262126
21272127 if (res && (nch > 1 ))
21282128 res = validate_test (CHILD (tree , 1 ));
2129- if (res && (nch == 4 ))
2130- res = (validate_comma (CHILD (tree , 2 ))
2131- && validate_test (CHILD (tree , 3 )));
2132-
2129+ if (res && (nch == 4 )) {
2130+ if (TYPE (CHILD (tree , 2 )) == NAME )
2131+ res = validate_name (CHILD (tree , 2 ), "as" );
2132+ else
2133+ res = validate_comma (CHILD (tree , 2 ));
2134+ res = res && validate_test (CHILD (tree , 3 ));
2135+ }
21332136 return (res );
21342137}
21352138
You can’t perform that action at this time.
0 commit comments