From: Robert Bradshaw Date: Wed, 8 Oct 2008 07:05:25 +0000 (-0700) Subject: Fix ticket #72, (compiler crash on bad code) X-Git-Tag: 0.9.9.2.beta~57 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e48bc77a49447eedb8d753fd293509e7f934956f;p=cython.git Fix ticket #72, (compiler crash on bad code) --- diff --git a/Cython/Compiler/Optimize.py b/Cython/Compiler/Optimize.py index 07f2e0fb..c26bd913 100644 --- a/Cython/Compiler/Optimize.py +++ b/Cython/Compiler/Optimize.py @@ -39,12 +39,12 @@ class SwitchTransform(Visitor.VisitorTransform): if is_common_value(cond.operand1, cond.operand1): if isinstance(cond.operand2, ExprNodes.ConstNode): return cond.operand1, [cond.operand2] - elif hasattr(cond.operand2, 'entry') and cond.operand2.entry.is_const: + elif hasattr(cond.operand2, 'entry') and cond.operand2.entry and cond.operand2.entry.is_const: return cond.operand1, [cond.operand2] if is_common_value(cond.operand2, cond.operand2): if isinstance(cond.operand1, ExprNodes.ConstNode): return cond.operand2, [cond.operand1] - elif hasattr(cond.operand1, 'entry') and cond.operand1.entry.is_const: + elif hasattr(cond.operand1, 'entry') and cond.operand1.entry and cond.operand1.entry.is_const: return cond.operand2, [cond.operand1] elif (isinstance(cond, ExprNodes.BoolBinopNode) and cond.operator == 'or'):