From a2f917aba314bdd344aaa7cd5347dfbad4d355b2 Mon Sep 17 00:00:00 2001 From: Allison Kaptur Date: Mon, 9 Jun 2014 16:33:11 -0400 Subject: [PATCH] raise hy compile error on Py2.x for raise from --- hy/compiler.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/hy/compiler.py b/hy/compiler.py index 96074c6..eeb2bb4 100644 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -680,12 +680,13 @@ class HyASTCompiler(object): ret += self.compile(expr.pop(0)) cause = None - if PY3: - if len(expr) == 2: - if expr[0] == HyKeyword(":from"): - expr.pop(0) - cause = self.compile(expr.pop(0)) - cause = cause.expr + if len(expr) == 2 and expr[0] == HyKeyword(":from"): + if not PY3: + raise HyCompileError( + "raise from only supported in python 3") + expr.pop(0) + cause = self.compile(expr.pop(0)) + cause = cause.expr # Use ret.expr to get a literal `None` ret += ast.Raise(