[Python-checkins] r82400 - in python/trunk: Lib/test/test_parser.py Misc/NEWS Modules/parsermodule.c
mark.dickinson
python-checkins at python.org
Wed Jun 30 18:27:57 CEST 2010
Author: mark.dickinson
Date: Wed Jun 30 18:27:57 2010
New Revision: 82400
Log:
Issue #9125: Update parser module for "except ... as ..." syntax.
Modified:
python/trunk/Lib/test/test_parser.py
python/trunk/Misc/NEWS
python/trunk/Modules/parsermodule.c
Modified: python/trunk/Lib/test/test_parser.py
==============================================================================
--- python/trunk/Lib/test/test_parser.py (original)
+++ python/trunk/Lib/test/test_parser.py Wed Jun 30 18:27:57 2010
@@ -235,6 +235,12 @@
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.
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Wed Jun 30 18:27:57 2010
@@ -20,6 +20,7 @@
- Issue #9075: In the ssl module, remove the setting of a ``debug`` flag
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?
=============================================
Modified: python/trunk/Modules/parsermodule.c
==============================================================================
--- python/trunk/Modules/parsermodule.c (original)
+++ python/trunk/Modules/parsermodule.c Wed Jun 30 18:27:57 2010
@@ -2126,10 +2126,13 @@
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);
}
More information about the Python-checkins
mailing list