range optimisation fixes
authorStefan Behnel <scoder@users.berlios.de>
Thu, 15 May 2008 09:19:23 +0000 (11:19 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Thu, 15 May 2008 09:19:23 +0000 (11:19 +0200)
Cython/Compiler/Nodes.py

index 352ee77e558ef4368bfcb6a02b51bd4e4f382590..dc42009d6d4f1945528e7bd06957cdbd3b315a7e 100644 (file)
@@ -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