diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2010-06-30 16:33:23 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2010-06-30 16:33:23 (GMT) |
commit | 9f11f397586b4cc596a9771350daed7f5e8e3e54 (patch) | |
tree | 537c34974e3ad8281823fece2bb6828305696eec | |
parent | 284bc0e711debadfaf30c7c18ef51bbe985a78d5 (diff) | |
download | cpython-9f11f397586b4cc596a9771350daed7f5e8e3e54.zip cpython-9f11f397586b4cc596a9771350daed7f5e8e3e54.tar.gz cpython-9f11f397586b4cc596a9771350daed7f5e8e3e54.tar.bz2 |
Merged revisions 82400 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r82400 | mark.dickinson | 2010-06-30 17:27:57 +0100 (Wed, 30 Jun 2010) | 2 lines
Issue #9125: Update parser module for "except ... as ..." syntax.
........
-rw-r--r-- | Lib/test/test_parser.py | 6 | ||||
-rw-r--r-- | Misc/NEWS | 2 | ||||
-rw-r--r-- | Modules/parsermodule.c | 11 |
3 files changed, 15 insertions, 4 deletions
diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py index 23f418e..ca5f43f 100644 --- a/Lib/test/test_parser.py +++ b/Lib/test/test_parser.py @@ -210,6 +210,12 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase): self.check_suite("try: pass\nexcept: pass\nelse: pass\n" "finally: pass\n") + def test_except_clause(self): + self.check_suite("try: pass\nexcept: pass\n") + self.check_suite("try: pass\nexcept A: pass\n") + self.check_suite("try: pass\nexcept A, e: pass\n") + self.check_suite("try: pass\nexcept A as e: pass\n") + def test_position(self): # An absolutely minimal test of position information. Better # tests would be a big project. @@ -73,6 +73,8 @@ C-API Library ------- +- Issue #9125: Add recognition of 'except ... as ...' syntax to parser module. + - Issue #9085: email package version number bumped to its correct value of 4.0.2 (same as it was in 2.5). diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c index 425d97f..365ec90 100644 --- a/Modules/parsermodule.c +++ b/Modules/parsermodule.c @@ -2126,10 +2126,13 @@ validate_except_clause(node *tree) if (res && (nch > 1)) res = validate_test(CHILD(tree, 1)); - if (res && (nch == 4)) - res = (validate_comma(CHILD(tree, 2)) - && validate_test(CHILD(tree, 3))); - + if (res && (nch == 4)) { + if (TYPE(CHILD(tree, 2)) == NAME) + res = validate_name(CHILD(tree, 2), "as"); + else + res = validate_comma(CHILD(tree, 2)); + res = res && validate_test(CHILD(tree, 3)); + } return (res); } |