summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorCollin Winter <collinw@gmail.com>2007-05-18 23:11:24 (GMT)
committerCollin Winter <collinw@gmail.com>2007-05-18 23:11:24 (GMT)
commit6290305e6722c20e17d3c73bd6a30c6448bead83 (patch)
treefc3cc9d13179cb407116ebac000400c9c294140a /Lib
parent6eb7bede72f044b0b6a73551c04281defc7fc489 (diff)
downloadcpython-6290305e6722c20e17d3c73bd6a30c6448bead83.zip
cpython-6290305e6722c20e17d3c73bd6a30c6448bead83.tar.gz
cpython-6290305e6722c20e17d3c73bd6a30c6448bead83.tar.bz2
Backport PEP 3110's new 'except' syntax to 2.6.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/compiler/transformer.py2
-rw-r--r--Lib/test/test_grammar.py4
2 files changed, 3 insertions, 3 deletions
diff --git a/Lib/compiler/transformer.py b/Lib/compiler/transformer.py
index ac23ad1..77ac776 100644
--- a/Lib/compiler/transformer.py
+++ b/Lib/compiler/transformer.py
@@ -930,7 +930,7 @@ class Transformer:
for i in range(3, len(nodelist), 3):
node = nodelist[i]
if node[0] == symbol.except_clause:
- # except_clause: 'except' [expr [',' expr]] */
+ # except_clause: 'except' [expr [(',' | 'as') expr]] */
if len(node) > 2:
expr1 = self.com_node(node[2])
if len(node) > 4:
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index 14ce7e4..51d77f2 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -600,7 +600,7 @@ hello world
def testTry(self):
### try_stmt: 'try' ':' suite (except_clause ':' suite)+ ['else' ':' suite]
### | 'try' ':' suite 'finally' ':' suite
- ### except_clause: 'except' [expr [',' expr]]
+ ### except_clause: 'except' [expr [('as' | ',') expr]]
try:
1/0
except ZeroDivisionError:
@@ -609,7 +609,7 @@ hello world
pass
try: 1/0
except EOFError: pass
- except TypeError, msg: pass
+ except TypeError as msg: pass
except RuntimeError, msg: pass
except: pass
else: pass