gurudesh/pytracebugs huggingface dataset:
# Buggy code
def match(self, interp, block, typemap, calltypes):
    self.raises = raises = {}
    self.block = block
    # Detect all raise statements and find which ones can be
    # rewritten
    for inst in block.find_insts(ir.Raise):
        if inst.exception is None:
            # re-reraise
            exc_type, exc_args = None, None
        else:
            # raise <something> => find the definition site for <something>
            const = interp.infer_constant(inst.exception)
            exc_type, exc_args = self._break_constant(interp, const)
        raises[inst] = exc_type, exc_args

    return len(raises) > 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 match(self, func_ir, block, typemap, calltypes):
    self.raises = raises = {}
    self.block = block
    # Detect all raise statements and find which ones can be
    # rewritten
    for inst in block.find_insts(ir.Raise):
        if inst.exception is None:
            # re-reraise
            exc_type, exc_args = None, None
        else:
            # raise <something> => find the definition site for <something>
            const = func_ir.infer_constant(inst.exception)
            exc_type, exc_args = self._break_constant(const)
        raises[inst] = exc_type, exc_args

    return len(raises) > 0
# Buggy code
def enum_eq(context, builder, sig, args):
    tu, tv = sig.args
    u, v = args
    res = context.generic_compare(builder, "!=", (tu.dtype, tv.dtype), (u, v))
    return impl_ret_untracked(context, builder, sig.return_type, res)


# 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 enum_eq(context, builder, sig, args):
    tu, tv = sig.args
    u, v = args
    res = context.generic_compare(builder, "==", (tu.dtype, tv.dtype), (u, v))
    return impl_ret_untracked(context, builder, sig.return_type, res)
# Buggy code
def codegen(context, builder, sig, args):
    (value,) = args
    iter_type = range_impl_map[val_type][1]
    state = cgutils.create_struct_proxy(iter_type)(context, builder, value)
    int_type = state.count.type
    return impl_ret_untracked(context, builder, int_type, builder.load(state.count))


# 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 codegen(context, builder, sig, args):
    (iterty,) = sig.args
    (value,) = args
    intp_t = context.get_value_type(types.intp)
    iterobj = context.make_helper(builder, iterty, value=value)
    arrayty = iterty.array_type
    ary = make_array(arrayty)(context, builder, value=iterobj.array)
    shape = cgutils.unpack_tuple(builder, ary.shape)
    # array iterates along the outer dimension
    return impl_ret_untracked(context, builder, intp_t, shape[0])
# Buggy code
def refine(self, typeinfer, target_type):
    # Do not back-propagate to locked variables (e.g. constants)
    typeinfer.add_type(self.src, target_type, unless_locked=True, loc=self.loc)


# 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 refine(self, typeinfer, target_type):
    # Do not back-propagate to locked variables (e.g. constants)
    assert target_type.is_precise()
    typeinfer.add_type(self.src, target_type, unless_locked=True, loc=self.loc)
# Buggy code
def __call__(self, typeinfer):
    with new_error_context("typing of argument at {0}", self.loc):
        typevars = typeinfer.typevars
        src = typevars[self.src]
        if not src.defined:
            return
        ty = src.getone()
        if isinstance(ty, types.Omitted):
            ty = typeinfer.context.resolve_value_type(ty.value)
        typeinfer.add_type(self.dst, ty, loc=self.loc)


# 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 __call__(self, typeinfer):
    with new_error_context("typing of argument at {0}", self.loc):
        typevars = typeinfer.typevars
        src = typevars[self.src]
        if not src.defined:
            return
        ty = src.getone()
        if isinstance(ty, types.Omitted):
            ty = typeinfer.context.resolve_value_type(ty.value)
        assert ty.is_precise()
        typeinfer.add_type(self.dst, ty, loc=self.loc)
# Buggy code
def __call__(self, typeinfer):
    with new_error_context("typing of tuple at {0}", self.loc):
        typevars = typeinfer.typevars
        tsets = [typevars[i.name].get() for i in self.items]
        oset = typevars[self.target]
        for vals in itertools.product(*tsets):
            if vals and all(vals[0] == v for v in vals):
                tup = types.UniTuple(dtype=vals[0], count=len(vals))
            else:
                # empty tuples fall here as well
                tup = types.Tuple(vals)
            typeinfer.add_type(self.target, tup, loc=self.loc)


# 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 __call__(self, typeinfer):
    with new_error_context("typing of tuple at {0}", self.loc):
        typevars = typeinfer.typevars
        tsets = [typevars[i.name].get() for i in self.items]
        oset = typevars[self.target]
        for vals in itertools.product(*tsets):
            if vals and all(vals[0] == v for v in vals):
                tup = types.UniTuple(dtype=vals[0], count=len(vals))
            else:
                # empty tuples fall here as well
                tup = types.Tuple(vals)
            assert tup.is_precise()
            typeinfer.add_type(self.target, tup, loc=self.loc)
# Buggy code
def __call__(self, typeinfer):
    with new_error_context("typing of pair-first at {0}", self.loc):
        typevars = typeinfer.typevars
        oset = typevars[self.target]
        for tp in typevars[self.pair.name].get():
            if not isinstance(tp, types.Pair):
                # XXX is this an error?
                continue
            typeinfer.add_type(self.target, tp.first_type, loc=self.loc)


# 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 __call__(self, typeinfer):
    with new_error_context("typing of pair-first at {0}", self.loc):
        typevars = typeinfer.typevars
        oset = typevars[self.target]
        for tp in typevars[self.pair.name].get():
            if not isinstance(tp, types.Pair):
                # XXX is this an error?
                continue
            assert tp.first_type.is_precise()
            typeinfer.add_type(self.target, tp.first_type, loc=self.loc)
# Buggy code
def __call__(self, typeinfer):
    with new_error_context("typing of pair-second at {0}", self.loc):
        typevars = typeinfer.typevars
        oset = typevars[self.target]
        for tp in typevars[self.pair.name].get():
            if not isinstance(tp, types.Pair):
                # XXX is this an error?
                continue
            typeinfer.add_type(self.target, tp.second_type, loc=self.loc)


# 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 __call__(self, typeinfer):
    with new_error_context("typing of pair-second at {0}", self.loc):
        typevars = typeinfer.typevars
        oset = typevars[self.target]
        for tp in typevars[self.pair.name].get():
            if not isinstance(tp, types.Pair):
                # XXX is this an error?
                continue
            assert tp.second_type.is_precise()
            typeinfer.add_type(self.target, tp.second_type, loc=self.loc)
# Buggy code
def __call__(self, typeinfer):
    with new_error_context("typing of static-get-item at {0}", self.loc):
        typevars = typeinfer.typevars
        oset = typevars[self.target]
        for ty in typevars[self.value.name].get():
            itemty = typeinfer.context.resolve_static_getitem(
                value=ty, index=self.index
            )
            if itemty is not None:
                typeinfer.add_type(self.target, itemty, loc=self.loc)
            elif self.fallback is not None:
                self.fallback(typeinfer)


# 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 __call__(self, typeinfer):
    with new_error_context("typing of static-get-item at {0}", self.loc):
        typevars = typeinfer.typevars
        oset = typevars[self.target]
        for ty in typevars[self.value.name].get():
            itemty = typeinfer.context.resolve_static_getitem(
                value=ty, index=self.index
            )
            if itemty is not None:
                assert itemty.is_precise()
                typeinfer.add_type(self.target, itemty, loc=self.loc)
            elif self.fallback is not None:
                self.fallback(typeinfer)
# Buggy code
def __call__(self, typeinfer):
    with new_error_context("typing of get attribute at {0}", self.loc):
        typevars = typeinfer.typevars
        valtys = typevars[self.value.name].get()
        for ty in valtys:
            attrty = typeinfer.context.resolve_getattr(ty, self.attr)
            if attrty is None:
                raise UntypedAttributeError(ty, self.attr, loc=self.inst.loc)
            else:
                typeinfer.add_type(self.target, attrty, loc=self.loc)
        typeinfer.refine_map[self.target] = self


# 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 __call__(self, typeinfer):
    with new_error_context("typing of get attribute at {0}", self.loc):
        typevars = typeinfer.typevars
        valtys = typevars[self.value.name].get()
        for ty in valtys:
            attrty = typeinfer.context.resolve_getattr(ty, self.attr)
            if attrty is None:
                raise UntypedAttributeError(ty, self.attr, loc=self.inst.loc)
            else:
                assert attrty.is_precise()
                typeinfer.add_type(self.target, attrty, loc=self.loc)
        typeinfer.refine_map[self.target] = self
# Buggy code
def refine(self, typeinfer, target_type):
    if isinstance(target_type, types.BoundFunction):
        recvr = target_type.this
        typeinfer.add_type(self.value.name, recvr, loc=self.loc)
        source_constraint = typeinfer.refine_map.get(self.value.name)
        if source_constraint is not None:
            source_constraint.refine(typeinfer, recvr)


# 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 refine(self, typeinfer, target_type):
    if isinstance(target_type, types.BoundFunction):
        recvr = target_type.this
        assert recvr.is_precise()
        typeinfer.add_type(self.value.name, recvr, loc=self.loc)
        source_constraint = typeinfer.refine_map.get(self.value.name)
        if source_constraint is not None:
            source_constraint.refine(typeinfer, recvr)
# Buggy code
def __call__(self, typeinfer):
    with new_error_context("typing of setitem at {0}", self.loc):
        typevars = typeinfer.typevars
        if not all(
            typevars[var.name].defined for var in (self.target, self.index, self.value)
        ):
            return
        targetty = typevars[self.target.name].getone()
        idxty = typevars[self.index.name].getone()
        valty = typevars[self.value.name].getone()

        sig = typeinfer.context.resolve_setitem(targetty, idxty, valty)
        if sig is None:
            raise TypingError(
                "Cannot resolve setitem: %s[%s] = %s" % (targetty, idxty, valty),
                loc=self.loc,
            )
        self.signature = sig


# 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 __call__(self, typeinfer):
    with new_error_context("typing of setitem at {0}", self.loc):
        typevars = typeinfer.typevars
        if not all(
            typevars[var.name].defined for var in (self.target, self.index, self.value)
        ):
            return
        targetty = typevars[self.target.name].getone()
        idxty = typevars[self.index.name].getone()
        valty = typevars[self.value.name].getone()

        sig = typeinfer.context.resolve_setitem(targetty, idxty, valty)
        if sig is None:
            raise TypingError(
                "Cannot resolve setitem: %s[%s] = %s" % (targetty, idxty, valty),
                loc=self.loc,
            )

        # For array setitem, refine imprecise array dtype
        if _is_array_not_precise(targetty):
            assert sig.args[0].is_precise()
            typeinfer.add_type(self.target.name, sig.args[0], loc=self.loc)

        self.signature = sig
# Buggy code
def constrain_statement(self, inst):
    if isinstance(inst, ir.Assign):
        self.typeof_assign(inst)
    elif isinstance(inst, ir.SetItem):
        self.typeof_setitem(inst)
    elif isinstance(inst, ir.StaticSetItem):
        self.typeof_static_setitem(inst)
    elif isinstance(inst, ir.DelItem):
        self.typeof_delitem(inst)
    elif isinstance(inst, ir.SetAttr):
        self.typeof_setattr(inst)
    elif isinstance(inst, ir.Print):
        self.typeof_print(inst)
    elif isinstance(inst, (ir.Jump, ir.Branch, ir.Return, ir.Del)):
        pass
    elif isinstance(inst, ir.StaticRaise):
        pass
    else:
        raise NotImplementedError(inst)


# 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 constrain_statement(self, inst):
    if isinstance(inst, ir.Assign):
        self.typeof_assign(inst)
    elif isinstance(inst, ir.SetItem):
        self.typeof_setitem(inst)
    elif isinstance(inst, ir.StaticSetItem):
        self.typeof_static_setitem(inst)
    elif isinstance(inst, ir.DelItem):
        self.typeof_delitem(inst)
    elif isinstance(inst, ir.SetAttr):
        self.typeof_setattr(inst)
    elif isinstance(inst, ir.Print):
        self.typeof_print(inst)
    elif isinstance(inst, (ir.Jump, ir.Branch, ir.Return, ir.Del)):
        pass
    elif isinstance(inst, ir.StaticRaise):
        pass
    elif type(inst) in typeinfer_extensions:
        # let external calls handle stmt if type matches
        f = typeinfer_extensions[type(inst)]
        f(inst, self)
    else:
        raise NotImplementedError(inst)
# Buggy code
def unify(self, typingctx, other):
    """
    Unify this with the *other* Array.
    """
    if (
        isinstance(other, Array)
        and other.ndim == self.ndim
        and other.dtype == self.dtype
    ):
        if self.layout == other.layout:
            layout = self.layout
        else:
            layout = "A"
        readonly = not (self.mutable and other.mutable)
        aligned = self.aligned and other.aligned
        return Array(
            dtype=self.dtype,
            ndim=self.ndim,
            layout=layout,
            readonly=readonly,
            aligned=aligned,
        )


# 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 unify(self, typingctx, other):
    """
    Unify this with the *other* Array.
    """
    # If other is array and the ndim matches
    if isinstance(other, Array) and other.ndim == self.ndim:
        # If dtype matches or other.dtype is undefined (inferred)
        if other.dtype == self.dtype or not other.dtype.is_precise():
            if self.layout == other.layout:
                layout = self.layout
            else:
                layout = "A"
            readonly = not (self.mutable and other.mutable)
            aligned = self.aligned and other.aligned
            return Array(
                dtype=self.dtype,
                ndim=self.ndim,
                layout=layout,
                readonly=readonly,
                aligned=aligned,
            )
# Buggy code
def generic_expand(self, args, kws):
    return signature(_expand_integer(self.this.dtype), recvr=self.this)


# 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 generic_expand(self, args, kws):
    assert not args
    assert not kws
    return signature(_expand_integer(self.this.dtype), recvr=self.this)
# Buggy code
def generic_expand_cumulative(self, args, kws):
    assert isinstance(self.this, types.Array)
    return_type = types.Array(
        dtype=_expand_integer(self.this.dtype), ndim=1, layout="C"
    )
    return signature(return_type, recvr=self.this)


# 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 generic_expand_cumulative(self, args, kws):
    assert not args
    assert not kws
    assert isinstance(self.this, types.Array)
    return_type = types.Array(
        dtype=_expand_integer(self.this.dtype), ndim=1, layout="C"
    )
    return signature(return_type, recvr=self.this)
# Buggy code
def generic(self, args, kws):
    (arg,) = args
    if self.is_accepted_type(arg):
        return signature(types.none, *args)


# 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 generic(self, args, kws):
    (arg,) = args
    return signature(types.none, *args)
# Buggy code
def __init__(self, variable, access_type, location):
    self.variable = variable
    self.access_type = access_type
    self.location = location


# Traceback (AttributeError)
Traceback (most recent call last):
File "/home/dnivra/angr-dev/angr-management/angrmanagement/ui/main_window.py", line 496, in decompile_current_function
self.workspace.decompile_current_function()
File "/home/dnivra/angr-dev/angr-management/angrmanagement/ui/workspace.py", line 265, in decompile_current_function
view.decompile_current_function()
File "/home/dnivra/angr-dev/angr-management/angrmanagement/ui/views/disassembly_view.py", line 382, in decompile_current_function
self.workspace.decompile_function(self._current_function.am_obj)
File "/home/dnivra/angr-dev/angr-management/angrmanagement/ui/workspace.py", line 279, in decompile_function
view.function = func
File "/home/dnivra/angr-dev/angr-management/angrmanagement/ui/views/code_view.py", line 66, in function
self.decompile()
File "/home/dnivra/angr-dev/angr-management/angrmanagement/ui/views/code_view.py", line 43, in decompile
d = self.workspace.instance.project.analyses.Decompiler(
File "/home/dnivra/angr-dev/angr/angr/analyses/analysis.py", line 115, in __call__
oself.__init__(*args, **kwargs)
File "/home/dnivra/angr-dev/angr/angr/analyses/decompiler/decompiler.py", line 24, in __init__
self._decompile()
File "/home/dnivra/angr-dev/angr/angr/analyses/decompiler/decompiler.py", line 41, in _decompile
clinic = self.project.analyses.Clinic(self.func,
File "/home/dnivra/angr-dev/angr/angr/analyses/analysis.py", line 115, in __call__
oself.__init__(*args, **kwargs)
File "/home/dnivra/angr-dev/angr/angr/analyses/decompiler/clinic.py", line 70, in __init__
self._analyze()
File "/home/dnivra/angr-dev/angr/angr/analyses/decompiler/clinic.py", line 138, in _analyze
ail_graph = self._make_returns(ail_graph)
File "/home/dnivra/angr-dev/angr/angr/utils/timing.py", line 28, in timed_func
return func(*args, **kwargs)
File "/home/dnivra/angr-dev/angr/angr/analyses/decompiler/clinic.py", line 457, in _make_returns
AILGraphWalker(ail_graph, _handler, replace_nodes=True).walk()
File "/home/dnivra/angr-dev/angr/angr/analyses/decompiler/ailgraph_walker.py", line 23, in walk
r = self.handler(node)
File "/home/dnivra/angr-dev/angr/angr/analyses/decompiler/clinic.py", line 453, in _handler
walker.walk(block)
File "/home/dnivra/angr-dev/angr/angr/analyses/decompiler/ailblock_walker.py", line 37, in walk
self._handle_stmt(i, stmt, block)
File "/home/dnivra/angr-dev/angr/angr/analyses/decompiler/ailblock_walker.py", line 50, in _handle_stmt
return handler(stmt_idx, stmt, block)
File "/home/dnivra/angr-dev/angr/angr/analyses/decompiler/clinic.py", line 434, in _handle_Return
and self.function.calling_convention.ret_val is not None:
AttributeError: 'NoneType' object has no attribute 'ret_val'

# Fixed code
def __init__(self, variable, access_type, location):
    self.variable = variable
    self.access_type = access_type
    self.location: "CodeLocation" = location
# Buggy code
def _next_code_addr(self):
    while True:
        addr = self._next_code_addr_core()
        if addr is None:
            return None

        # if the new address is already occupied
        if not self._seg_list.is_occupied(addr):
            return addr


# Traceback (TypeError)
Traceback (most recent call last):
File "test.py", line 4, in <module>
cfg = proj.analyses.CFGFast(show_progressbar=True)
File "/home/angr_fork/angr/analyses/analysis.py", line 115, in __call__
oself.__init__(*args, **kwargs)
File "/home/angr_fork/angr/analyses/cfg/cfg_fast.py", line 653, in __init__
self._analyze()
File "/home/angr_fork/angr/analyses/forward_analysis/forward_analysis.py", line 216, in _analyze
self._analysis_core_baremetal()
File "/home/angr_fork/angr/analyses/forward_analysis/forward_analysis.py", line 344, in _analysis_core_baremetal
self._job_queue_empty()
File "/home/angr_fork/angr/analyses/cfg/cfg_fast.py", line 1192, in _job_queue_empty
if any(re.match(prolog, bytes_prefix) for prolog in self.project.arch.thumb_prologs):
File "/home/angr_fork/angr/analyses/cfg/cfg_fast.py", line 1192, in <genexpr>
if any(re.match(prolog, bytes_prefix) for prolog in self.project.arch.thumb_prologs):
File "/home/angr_fork/venv/lib/python3.6/re.py", line 172, in match
return _compile(pattern, flags).match(string)
TypeError: expected string or bytes-like object

# Fixed code
def _next_code_addr(self):
    while True:
        try:
            addr = self._next_code_addr_core()
        except ContinueScanningNotification:
            continue

        if addr is None:
            return None

        # if the new address is already occupied
        if not self._seg_list.is_occupied(addr):
            return addr
# Buggy code
def _return_from_call(self, from_func, to_node, to_outside=False):
    self.transition_graph.add_edge(
        from_func, to_node, type="real_return", to_outside=to_outside
    )
    for _, _, data in self.transition_graph.in_edges(to_node, data=True):
        if "type" in data and data["type"] == "fake_return":
            data["confirmed"] = True

    self._local_transition_graph = None


# Traceback (TypeError)
File "angr/angr/angrdb/db.py", line 36, in open_db
yield Session
File "angr/angr/angrdb/db.py", line 143, in dump
KnowledgeBaseSerializer.dump(session, self.project.kb)
File "angr/angr/angrdb/serializers/kb.py", line 36, in dump
FunctionManagerSerializer.dump(session, db_kb, kb.functions)
File "angr/angr/angrdb/serializers/funcs.py", line 29, in dump
blob=func.serialize(),
File "angr/angr/serializable.py", line 37, in serialize
return self.serialize_to_cmessage().SerializeToString()
File "angr/angr/knowledge_plugins/functions/function.py", line 388, in serialize_to_cmessage
return FunctionParser.serialize(self)
File "angr/angr/knowledge_plugins/functions/function_parser.py", line 58, in serialize
edge.jumpkind = func_edge_type_to_pb(value)
TypeError: None has type NoneType, but expected one of: int, long

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "fuzz_driver.py", line 474, in <module>
db.dump(db_file)
File "angr/angr/angrdb/db.py", line 145, in dump
self.update_dbinfo(session)
File "/usr/lib/python3.6/contextlib.py", line 99, in __exit__
self.gen.throw(type, value, traceback)
File "angr/angr/angrdb/db.py", line 40, in open_db
raise AngrDBError(str(ex))
angr.errors.AngrDBError: None has type NoneType, but expected one of: int, long

# Fixed code
def _return_from_call(self, from_func, to_node, to_outside=False):
    self.transition_graph.add_edge(
        from_func, to_node, type="return", to_outside=to_outside
    )
    for _, _, data in self.transition_graph.in_edges(to_node, data=True):
        if "type" in data and data["type"] == "fake_return":
            data["confirmed"] = True

    self._local_transition_graph = None
# Buggy code
def __repr__(self):
    return "<XRef %s: %s->%s>" % (
        XRefType.to_string(self.type),
        "%#x" % self.ins_addr
        if self.ins_addr is not None
        else "%#x[%d]" % (self.block_addr, self.stmt_idx),
        "%#x" % (self.dst if self.dst is not None else self.memory_data.addr),
    )


# Traceback (TypeError)
TypeError                                 Traceback (most recent call last)
----> 5 print(p.kb.xrefs.xrefs_by_ins_addr)

~/angr-dev/angr/angr/knowledge_plugins/xrefs/xref.py in __repr__(self)
43                 XRefType.to_string(self.type),
44                 "%#x" % self.ins_addr if self.ins_addr is not None else "%#x[%d]" % (self.block_addr, self.stmt_idx),
---> 45                 "%#x" % (self.dst if self.dst is not None else self.memory_data.addr)
46         )
47

TypeError: %x format: an integer is required, not SpOffset

# Fixed code
def __repr__(self):
    return "<XRef %s: %s->%s>" % (
        self.type_string,
        "%#x" % self.ins_addr
        if self.ins_addr is not None
        else "%#x[%d]" % (self.block_addr, self.stmt_idx),
        "%s" % self.dst if self.dst is not None else "%#x" % (self.memory_data.addr),
    )