From d467013cb4c4f651ef5265519959f1aa7a6ec9d0 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Thu, 15 May 2008 11:19:23 +0200 Subject: [PATCH] range optimisation fixes --- Cython/Compiler/Nodes.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 352ee77e..dc42009d 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -2990,15 +2990,16 @@ class ForInStatNode(LoopNode, StatNode): else: step = args[2] if isinstance(step, ExprNodes.UnaryMinusNode) and isinstance(step.operand, ExprNodes.IntNode): - step = ExprNodes.IntNode(pos = step.pos, value=-int(step.operand.value)) + step = ExprNodes.IntNode(pos = step.pos, value=str(-int(step.operand.value, 0))) if isinstance(step, ExprNodes.IntNode): - if step.value > 0: + step_value = int(step.value, 0) + if step_value > 0: self.step = step self.relation1 = '<=' self.relation2 = '<' return True - elif step.value < 0: - self.step = ExprNodes.IntNode(pos = step.pos, value=-int(step.value)) + elif step_value < 0: + self.step = ExprNodes.IntNode(pos = step.pos, value=str(-step_value)) self.relation1 = '>=' self.relation2 = '>' return True -- 2.26.2