def compile(code: list, consts: list, names: list, varnames: list,<EOL>func_name: str = "<STR_LIT>",<EOL>arg_count: int = <NUM_LIT:0>, kwarg_defaults: Tuple[Any] = (), use_safety_wrapper: bool = True):
varnames = tuple(varnames)<EOL>consts = tuple(consts)<EOL>names = tuple(names)<EOL>code = util.flatten(code)<EOL>if arg_count > len(varnames):<EOL><INDENT>raise CompileError("<STR_LIT>")<EOL><DEDENT>if len(kwarg_defaults) > len(varnames):<EOL><INDENT>raise CompileError("<STR_LIT>")<EOL><DEDENT>bc = compile_bytecode(code)<EOL>dis.dis(bc)<EOL>if PY36:<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>if bc[-<NUM_LIT:1>] != tokens.RETURN_VALUE:<EOL><INDENT>raise CompileError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT><DEDENT>flags = <NUM_LIT:1> | <NUM_LIT:2> | <NUM_LIT:64><EOL>frame_data = inspect.stack()[<NUM_LIT:1>]<EOL>if sys.version_info[<NUM_LIT:0>:<NUM_LIT:2>] > (<NUM_LIT:3>, <NUM_LIT:3>):<EOL><INDENT>stack_size = _simulate_stack(dis._get_instructions_bytes(<EOL>bc, constants=consts, names=names, varnames=varnames)<EOL>)<EOL><DEDENT>else:<EOL><INDENT>warnings.warn("<STR_LIT>")<EOL>stack_size = <NUM_LIT><EOL><DEDENT>_optimize_warn_pass(dis._get_instructions_bytes(bc, constants=consts, names=names, varnames=varnames))<EOL>obb = types.CodeType(<EOL>arg_count,  <EOL><NUM_LIT:0>,  <EOL>len(varnames),  <EOL>stack_size,  <EOL>flags,  <EOL>bc,  <EOL>consts,  <EOL>names,  <EOL>varnames,  <EOL>frame_data[<NUM_LIT:1>],  <EOL>func_name,  <EOL>frame_data[<NUM_LIT:2>],  <EOL>b'<STR_LIT>',  <EOL>(),  <EOL>()  <EOL>)<EOL>f_globals = frame_data[<NUM_LIT:0>].f_globals<EOL>f = types.FunctionType(obb, f_globals)<EOL>f.__name__ = func_name<EOL>f.__defaults__ = kwarg_defaults<EOL>if use_safety_wrapper:<EOL><INDENT>def __safety_wrapper(*args, **kwargs):<EOL><INDENT>try:<EOL><INDENT>return f(*args, **kwargs)<EOL><DEDENT>except SystemError as e:<EOL><INDENT>if '<STR_LIT>' not in '<STR_LIT:U+0020>'.join(e.args):<EOL><INDENT>raise<EOL><DEDENT>msg = "<STR_LIT>""<STR_LIT>""<STR_LIT>".format(f.__name__)<EOL>file = io.StringIO()<EOL>with contextlib.redirect_stdout(file):<EOL><INDENT>dis.dis(f)<EOL><DEDENT>msg += file.getvalue()<EOL>raise SystemError(msg) from e<EOL><DEDENT><DEDENT>returned_func = __safety_wrapper<EOL>returned_func.wrapped = f<EOL><DEDENT>else:<EOL><INDENT>returned_func = f<EOL><DEDENT>return returned_func<EOL>
Compiles a set of bytecode instructions into a working function, using Python's bytecode
compiler.

:param code: A list of bytecode instructions.
:param consts: A list of constants to compile into the function.
:param names: A list of names to compile into the function.
:param varnames: A list of ``varnames`` to compile into the function.
:param func_name: The name of the function to use.
:param arg_count: The number of arguments this function takes. Must be ``<= len(varnames)``.
:param kwarg_defaults: A tuple of defaults for kwargs.
:param use_safety_wrapper: Use the safety wrapper? This hijacks SystemError to print better \
    stack traces.