Commits

Alex Gaynor  committed 681ae61

Fixed the bounds check in getitem, thanks to nightless_night for the patch.

  • Participants
  • Parent commits 40189e8
  • Branches numpy-exp

Comments (0)

Files changed (2)

File pypy/module/micronumpy/numarray.py

         if item < 0:
             raise operationerrfmt(space.w_TypeError,
               '%d below zero', item)
-        if item > self.size:
+        if item >= self.size:
             raise operationerrfmt(space.w_TypeError,
               '%d above array size', item)
         return space.wrap(self.storage[item])

File pypy/module/micronumpy/test/test_numpy.py

         a = array(range(5))
         assert a[3] == 3
 
+    def test_getitem(self):
+        from numpy import array
+        a = array(range(5))
+        raises(TypeError, "a[5]")
+        a = a + a
+        raises(TypeError, "a[5]")
+
     def test_add(self):
         from numpy import array
         a = array(range(5))