# Buggy code
def __init__(self, shape, strides, dtype, stream=0, writeback=None, gpu_data=None):
    """
    Args
    ----

    shape
        array shape.
    strides
        array strides.
    dtype
        data type as np.dtype.
    stream
        cuda stream.
    writeback
        Deprecated.
    gpu_data
        user provided device memory for the ndarray data buffer
    """
    if isinstance(shape, (int, long)):
        shape = (shape,)
    if isinstance(strides, (int, long)):
        strides = (strides,)
    self.ndim = len(shape)
    if len(strides) != self.ndim:
        raise ValueError("strides not match ndim")
    self._dummy = dummyarray.Array.from_desc(0, shape, strides, dtype.itemsize)
    self.shape = tuple(shape)
    self.strides = tuple(strides)
    self.dtype = np.dtype(dtype)
    self.size = int(np.prod(self.shape))
    # prepare gpu memory
    if self.size > 0:
        if gpu_data is None:
            self.alloc_size = _driver.memory_size_from_info(
                self.shape, self.strides, self.dtype.itemsize
            )
            gpu_data = devices.get_context().memalloc(self.alloc_size)
        else:
            self.alloc_size = _driver.device_memory_size(gpu_data)
    else:
        gpu_data = None
        self.alloc_size = 0

    self.gpu_data = gpu_data

    self.__writeback = writeback  # should deprecate the use of this
    self.stream = 0


# 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 __init__(self, shape, strides, dtype, stream=0, writeback=None, gpu_data=None):
    """
    Args
    ----

    shape
        array shape.
    strides
        array strides.
    dtype
        data type as np.dtype.
    stream
        cuda stream.
    writeback
        Deprecated.
    gpu_data
        user provided device memory for the ndarray data buffer
    """
    if isinstance(shape, (int, long)):
        shape = (shape,)
    if isinstance(strides, (int, long)):
        strides = (strides,)
    self.ndim = len(shape)
    if len(strides) != self.ndim:
        raise ValueError("strides not match ndim")
    self._dummy = dummyarray.Array.from_desc(0, shape, strides, dtype.itemsize)
    self.shape = tuple(shape)
    self.strides = tuple(strides)
    self.dtype = np.dtype(dtype)
    self.size = int(np.prod(self.shape))
    # prepare gpu memory
    if self.size > 0:
        if gpu_data is None:
            self.alloc_size = _driver.memory_size_from_info(
                self.shape, self.strides, self.dtype.itemsize
            )
            gpu_data = devices.get_context().memalloc(self.alloc_size)
        else:
            self.alloc_size = _driver.device_memory_size(gpu_data)
    else:
        # Make NULL pointer for empty allocation
        gpu_data = _driver.MemoryPointer(
            context=devices.get_context(), pointer=c_void_p(0), size=0
        )
        self.alloc_size = 0

    self.gpu_data = gpu_data

    self.__writeback = writeback  # should deprecate the use of this
    self.stream = 0