From 87b6002b6c645bd11a0d3daa48afb6d54f8f1981 Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Wed, 4 Mar 2015 00:31:55 +0100 Subject: [PATCH] Fix the bug detected in llListReplaceList. --- lslopt/lslbasefuncs.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lslopt/lslbasefuncs.py b/lslopt/lslbasefuncs.py index 35bc3e2..aebc1fd 100644 --- a/lslopt/lslbasefuncs.py +++ b/lslopt/lslbasefuncs.py @@ -1120,12 +1120,16 @@ def llListReplaceList(lst, elems, start, end): assert isinteger(start) assert isinteger(end) L = len(lst) + if start < -L: + # llListReplaceList([0,1,2,3],[5],-5,-5) should return [0,1,2,3] + # llListReplaceList([0,1,2,3],[5],-5,-4) should return [1,2,3] + # llListReplaceList([0,1,2,3],[5],-5,-7) should return [] + elems = [] if (start + L if start < 0 else start) > (end + L if end < 0 else end): # Exclusion range. Appends elems at 'start' i.e. at end :) if end == -1: end += L return lst[end+1:start] + elems if end == -1: end += L - # BUG: llListReplaceList([1,2,3,4],[5],-5,-5) should return [1,2,3,4] return lst[:start] + elems + lst[end+1:] def llListSort(lst, stride, asc):