off-by-one fix
authorStefan Behnel <scoder@users.berlios.de>
Fri, 14 Nov 2008 20:00:50 +0000 (21:00 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Fri, 14 Nov 2008 20:00:50 +0000 (21:00 +0100)
Cython/Compiler/ExprNodes.py

index 3d15ca9036a1121d514cf759a58a026f0dc50302..3f0ff191014bb76f7ef731215e7ad0f149b696df 100644 (file)
@@ -1828,7 +1828,6 @@ class SliceIndexNode(ExprNode):
                 else:
                     start_offset += '+'
             if rhs.type.is_array:
-                # FIXME: we should check both array sizes here
                 array_length = rhs.type.size
                 self.generate_slice_guard_code(code, array_length)
             else:
@@ -1863,10 +1862,10 @@ class SliceIndexNode(ExprNode):
             stop = self.stop.result()
             try:
                 stop = int(stop)
-                if stop > 0:
-                    slice_size = stop
-                else:
+                if stop < 0:
                     slice_size = self.base.type.size + stop
+                else:
+                    slice_size = stop
                 stop = None
             except ValueError:
                 pass