# Buggy code
def _loop_lift_get_candidate_infos(cfg, blocks, livemap):
    """
    Returns information on looplifting candidates.
    """
    loops = _extract_loop_lifting_candidates(cfg, blocks)
    loopinfos = []
    for loop in loops:
        [callfrom] = loop.entries  # requirement checked earlier
        an_exit = next(iter(loop.exits))  # anyone of the exit block
        [(returnto, _)] = cfg.successors(an_exit)  # requirement checked earlier
        # note: sorted for stable ordering
        inputs = sorted(livemap[callfrom])
        outputs = sorted(livemap[returnto])
        lli = _loop_lift_info(
            loop=loop,
            inputs=inputs,
            outputs=outputs,
            callfrom=callfrom,
            returnto=returnto,
        )
        loopinfos.append(lli)
    return loopinfos


# Traceback (ValueError)
Traceback (most recent call last):
File "numbabug.py", line 11, in <module>
numbafunc([])
File "/home/tuukka/.local/lib/python3.5/site-packages/numba/dispatcher.py", line 307, in _compile_for_args
return self.compile(tuple(argtypes))
File "/home/tuukka/.local/lib/python3.5/site-packages/numba/dispatcher.py", line 579, in compile
cres = self._compiler.compile(args, return_type)
File "/home/tuukka/.local/lib/python3.5/site-packages/numba/dispatcher.py", line 80, in compile
flags=flags, locals=self.locals)
File "/home/tuukka/.local/lib/python3.5/site-packages/numba/compiler.py", line 763, in compile_extra
return pipeline.compile_extra(func)
File "/home/tuukka/.local/lib/python3.5/site-packages/numba/compiler.py", line 360, in compile_extra
return self._compile_bytecode()
File "/home/tuukka/.local/lib/python3.5/site-packages/numba/compiler.py", line 722, in _compile_bytecode
return self._compile_core()
File "/home/tuukka/.local/lib/python3.5/site-packages/numba/compiler.py", line 709, in _compile_core
res = pm.run(self.status)
File "/home/tuukka/.local/lib/python3.5/site-packages/numba/compiler.py", line 246, in run
raise patched_exception
File "/home/tuukka/.local/lib/python3.5/site-packages/numba/compiler.py", line 238, in run
stage()
File "/home/tuukka/.local/lib/python3.5/site-packages/numba/compiler.py", line 431, in stage_objectmode_frontend
cres = self.frontend_looplift()
File "/home/tuukka/.local/lib/python3.5/site-packages/numba/compiler.py", line 411, in frontend_looplift
flags=loop_flags)
File "/home/tuukka/.local/lib/python3.5/site-packages/numba/transforms.py", line 191, in loop_lifting
func_ir.variable_lifetime.livemap)
File "/home/tuukka/.local/lib/python3.5/site-packages/numba/transforms.py", line 59, in _loop_lift_get_candidate_infos
[(returnto, _)] = cfg.successors(an_exit)  # requirement checked earlier
ValueError: Failed at object (object mode frontend)
not enough values to unpack (expected 1, got 0)

# Fixed code
def _loop_lift_get_candidate_infos(cfg, blocks, livemap):
    """
    Returns information on looplifting candidates.
    """
    loops = _extract_loop_lifting_candidates(cfg, blocks)
    loopinfos = []
    for loop in loops:
        [callfrom] = loop.entries  # requirement checked earlier
        # This loop exists to handle missing cfg.successors, only *an* exit is
        # needed. Walk in stable order, higher exits first.
        for an_exit in iter(sorted(loop.exits)):
            # requirement checked earlier
            ret = [x for x in cfg.successors(an_exit)]
            if ret:
                break
        else:
            continue  # drop this loop from being liftable
        [(returnto, _)] = ret
        # note: sorted for stable ordering
        inputs = sorted(livemap[callfrom])
        outputs = sorted(livemap[returnto])
        lli = _loop_lift_info(
            loop=loop,
            inputs=inputs,
            outputs=outputs,
            callfrom=callfrom,
            returnto=returnto,
        )
        loopinfos.append(lli)
    return loopinfos