# Buggy code
def __getitem__(self, item):
    if isinstance(item, slice):
        start, stop, step = item.start, item.stop, item.step
        single = False
    else:
        single = True
        start = item
        stop = start + 1
        step = None

    if start is None:
        start = 0
    if stop is None:
        stop = self.size
    if step is None:
        step = 1

    stride = step * self.stride

    if start >= 0:
        start = self.start + start * self.stride
    else:
        start = self.stop + start * self.stride

    if stop >= 0:
        stop = self.start + stop * self.stride
    else:
        stop = self.stop + stop * self.stride

    size = (stop - start + (stride - 1)) // stride

    if self.start >= start >= self.stop:
        raise IndexError("start index out-of-bound")

    if self.start >= stop >= self.stop:
        raise IndexError("stop index out-of-bound")

    if stop < start:
        start = stop
        size = 0

    return Dim(start, stop, size, stride, single)


# Traceback (TypeError)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-15-3b23f7331ceb> in <module>()
----> 1 @jit(arg_types=[numba.double], ret_type=numba.double)
2 def is_REALLY_five(some_value):
3     for i in range(5):
4         if some_value == 5.0:
5             return 1.0

/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/numba/decorators.pyc in _jit(func)
77                   "garbage collected!" % (func,))
78         t = Translate(func, *args, **kws)
---> 79         t.translate()
80         __tr_map__[func] = t
81         return t.get_ctypes_func(llvm)

/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/numba/translate.pyc in translate(self)
926                     # Ensure we are playing with locals that might
927                     # actually precede the next block.
--> 928                     self.check_locals(i)
929
930                 self.crnt_block = i

/Library/Frameworks/EPD64.framework/Versions/7.3/lib/python2.7/site-packages/numba/translate.pyc in check_locals(self, i)
1135                 else:
1136                     assert next_locals is not None, "Internal compiler error!"
-> 1137             self._locals = next_locals[:]
1138
1139     def get_ctypes_func(self, llvm=True):

TypeError: 'NoneType' object has no attribute '__getitem__'

# Fixed code
def __getitem__(self, item):
    if isinstance(item, slice):
        start, stop, step = item.start, item.stop, item.step
        single = False
    else:
        single = True
        start = item
        stop = start + 1
        step = None

    # Default values
    #   Start value is default to zero
    if start is None:
        start = 0
    #   Stop value is default to self.size
    if stop is None:
        stop = self.size
    #   Step is default to 1
    if step is None:
        step = 1

    stride = step * self.stride

    # Compute start in bytes
    if start >= 0:
        start = self.start + start * self.stride
    else:
        start = self.stop + start * self.stride
    start = max(start, self.start)

    # Compute stop in bytes
    if stop >= 0:
        stop = self.start + stop * self.stride
    else:
        stop = self.stop + stop * self.stride
    stop = min(stop, self.stop)

    # Clip stop
    if (stop - start) > self.size * self.stride:
        stop = start + self.size * stride

    size = (stop - start + (stride - 1)) // stride

    if stop < start:
        start = stop
        size = 0

    return Dim(start, stop, size, stride, single)