From 10a7e5d2418e9d7afc652b03ef0686434bde8683 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Sun, 24 Mar 2013 12:17:52 -0400 Subject: [PATCH] Fix the same bug in __setitem__ and __delitem__ --- mwparserfromhell/smart_list.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mwparserfromhell/smart_list.py b/mwparserfromhell/smart_list.py index 47f7232..e42dbae 100644 --- a/mwparserfromhell/smart_list.py +++ b/mwparserfromhell/smart_list.py @@ -86,6 +86,7 @@ class SmartList(list): return super(SmartList, self).__setitem__(key, item) item = list(item) super(SmartList, self).__setitem__(key, item) + key = slice(key.start or 0, key.stop or maxsize) diff = len(item) - key.stop + key.start values = self._children.values if py3k else self._children.itervalues if diff: @@ -97,7 +98,9 @@ class SmartList(list): def __delitem__(self, key): super(SmartList, self).__delitem__(key) - if not isinstance(key, slice): + if isinstance(key, slice): + key = slice(key.start or 0, key.stop or maxsize) + else: key = slice(key, key + 1) diff = key.stop - key.start values = self._children.values if py3k else self._children.itervalues