2016-11-19 | Paul Boddie | raw files shortlog changelog graph | Prevent out-of-bounds access to lists. | |
lib/__builtins__/list.py (file) |
1.1 --- a/lib/__builtins__/list.py Sat Nov 19 18:30:54 2016 +0100 1.2 +++ b/lib/__builtins__/list.py Sat Nov 19 18:38:27 2016 +0100 1.3 @@ -96,7 +96,10 @@ 1.4 1.5 def __get_single_item__(self, index): 1.6 1.7 - "Return the item at 'index'." 1.8 + "Return the item at the normalised (positive) 'index'." 1.9 + 1.10 + if index >= len(self): 1.11 + raise IndexError(index) 1.12 1.13 return native._list_element(self, index) 1.14