1.1 --- a/lib/builtins.py Mon Nov 01 01:22:44 2010 +0100
1.2 +++ b/lib/builtins.py Mon Nov 01 01:50:24 2010 +0100
1.3 @@ -578,6 +578,7 @@
1.4 "Return the item or slice specified by 'index'."
1.5
1.6 if isinstance(index, int):
1.7 + index = _normalise_index(index, len(seq))
1.8 return seq.__get_single_item__(index)
1.9 elif isinstance(index, slice):
1.10 return seq.__getslice__(index.start, index.end)
2.1 --- a/micropython/trans.py Mon Nov 01 01:22:44 2010 +0100
2.2 +++ b/micropython/trans.py Mon Nov 01 01:50:24 2010 +0100
2.3 @@ -1144,7 +1144,10 @@
2.4 # Store the item in the namespace entry for the given name.
2.5
2.6 else:
2.7 + self.record_value()
2.8 self.new_op(StoreName(fn[parameter]))
2.9 + self.set_source()
2.10 + self.discard_value()
2.11
2.12 if parameters is not None:
2.13 self.discard_temp(temp_getitem)
3.1 --- a/rsvplib.py Mon Nov 01 01:22:44 2010 +0100
3.2 +++ b/rsvplib.py Mon Nov 01 01:50:24 2010 +0100
3.3 @@ -60,13 +60,8 @@
3.4 self.frame_stack = self.machine.frame_stack
3.5 self.local_sp_stack = self.machine.local_sp_stack
3.6
3.7 - def _get_absolute_index(self, pos, nelements):
3.8 - if pos >= 0 and pos < nelements:
3.9 - return pos
3.10 - elif pos < 0 and pos >= -nelements:
3.11 - return nelements + pos
3.12 - else:
3.13 - return None
3.14 + def _check_index(self, pos, nelements):
3.15 + return pos >= 0 and pos < nelements
3.16
3.17 def builtins_int_arithmetic_op(self, op):
3.18 frame = self.local_sp_stack[-1]
3.19 @@ -303,9 +298,7 @@
3.20
3.21 item_pos = self.machine.load(item_value.ref + 1)
3.22
3.23 - item_pos = self._get_absolute_index(item_pos, nelements)
3.24 -
3.25 - if item_pos is None:
3.26 + if not self._check_index(item_pos, nelements):
3.27 self.machine.exception = self.machine._MakeObject(2, self.index_error_instance)
3.28 return self.machine.RaiseException()
3.29
3.30 @@ -436,9 +429,7 @@
3.31
3.32 item_pos = self.machine.load(item_value.ref + 1)
3.33
3.34 - item_pos = self._get_absolute_index(item_pos, nelements)
3.35 -
3.36 - if item_pos is None:
3.37 + if not self._check_index(item_pos, nelements):
3.38 self.machine.exception = self.machine._MakeObject(2, self.index_error_instance)
3.39 return self.machine.RaiseException()
3.40