From: Stefan Behnel Date: Fri, 14 Nov 2008 20:00:50 +0000 (+0100) Subject: off-by-one fix X-Git-Tag: 0.11-beta~253 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4f8e669d0ec6a09dbe8f9efeda7a640e7a29ac35;p=cython.git off-by-one fix --- 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