def _create_function_from_code_obj(fcode, func_env, func_arg, func_clo, glbls):
    """
    Creates a function from a code object. Args:
    * fcode - the code object
    * func_env - string for the freevar placeholders
    * func_arg - string for the function args (e.g. "a, b, c, d=None")
    * func_clo - string for the closure args
    * glbls - the function globals
    """
    func_text = 'def g():\n%s\n  def f(%s):\n    return (%s)\n  return f' % (
        func_env, func_arg, func_clo)
    loc = {}
    exec(func_text, glbls, loc)
    f = loc['g']()
    f.__code__ = fcode
    f.__name__ = fcode.co_name
    return f
