From: Stefan Behnel Date: Sun, 14 Mar 2010 12:55:50 +0000 (+0100) Subject: fix except-as syntax to match Py3 X-Git-Tag: 0.13.beta0~288 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=abb7a118796a86741f95503e17d76f5ebd467a18;p=cython.git fix except-as syntax to match Py3 --- diff --git a/Cython/Compiler/Parsing.py b/Cython/Compiler/Parsing.py index 0443b118..8abd96b6 100644 --- a/Cython/Compiler/Parsing.py +++ b/Cython/Compiler/Parsing.py @@ -1335,13 +1335,11 @@ def p_except_clause(s): s.next() exc_value = p_simple_expr(s) elif s.sy == 'IDENT' and s.systring == 'as': - ## XXX In Python 3, it should be: - ## s.next() - ## pos2 = s.position() - ## name = p_ident(s) - ## exc_value = ExprNodes.NameNode(pos2, name = name) + # Py3 syntax requires a name here s.next() - exc_value = p_simple_expr(s) + pos2 = s.position() + name = p_ident(s) + exc_value = ExprNodes.NameNode(pos2, name = name) body = p_suite(s) return Nodes.ExceptClauseNode(pos, pattern = exc_type, target = exc_value, body = body) diff --git a/tests/compile/tryexcept.pyx b/tests/compile/tryexcept.pyx index 7be361bb..b1fcca92 100644 --- a/tests/compile/tryexcept.pyx +++ b/tests/compile/tryexcept.pyx @@ -76,9 +76,9 @@ def g(a, b, c, x): try: i = 1 - except (a, b) as c[42]: + except (a, b) as c: i = 2 - except (b, a) as c.x: + except (b, a) as c: i = 3 except: i = 4