From 4f8e669d0ec6a09dbe8f9efeda7a640e7a29ac35 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Fri, 14 Nov 2008 21:00:50 +0100 Subject: [PATCH] off-by-one fix --- Cython/Compiler/ExprNodes.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 3d15ca90..3f0ff191 100644 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -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 -- 2.26.2