mirror of https://github.com/python/cpython
Issue #9125: Update parser module for "except ... as ..." syntax.
This commit is contained in:
parent
2037913507
commit
070f0abc19
|
@ -235,6 +235,12 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
|
||||||
self.check_suite("try: pass\nexcept: pass\nelse: pass\n"
|
self.check_suite("try: pass\nexcept: pass\nelse: pass\n"
|
||||||
"finally: 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):
|
def test_position(self):
|
||||||
# An absolutely minimal test of position information. Better
|
# An absolutely minimal test of position information. Better
|
||||||
# tests would be a big project.
|
# tests would be a big project.
|
||||||
|
|
|
@ -20,6 +20,7 @@ Library
|
||||||
- Issue #9075: In the ssl module, remove the setting of a ``debug`` flag
|
- Issue #9075: In the ssl module, remove the setting of a ``debug`` flag
|
||||||
on an OpenSSL structure.
|
on an OpenSSL structure.
|
||||||
|
|
||||||
|
- Issue #9125: Add recognition of 'except ... as ...' syntax to parser module.
|
||||||
|
|
||||||
What's New in Python 2.7 release candidate 2?
|
What's New in Python 2.7 release candidate 2?
|
||||||
=============================================
|
=============================================
|
||||||
|
|
|
@ -2126,10 +2126,13 @@ validate_except_clause(node *tree)
|
||||||
|
|
||||||
if (res && (nch > 1))
|
if (res && (nch > 1))
|
||||||
res = validate_test(CHILD(tree, 1));
|
res = validate_test(CHILD(tree, 1));
|
||||||
if (res && (nch == 4))
|
if (res && (nch == 4)) {
|
||||||
res = (validate_comma(CHILD(tree, 2))
|
if (TYPE(CHILD(tree, 2)) == NAME)
|
||||||
&& validate_test(CHILD(tree, 3)));
|
res = validate_name(CHILD(tree, 2), "as");
|
||||||
|
else
|
||||||
|
res = validate_comma(CHILD(tree, 2));
|
||||||
|
res = res && validate_test(CHILD(tree, 3));
|
||||||
|
}
|
||||||
return (res);
|
return (res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue