<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def getcodeobj(consts, intcode, newcodeobj, oldcodeobj):
 """Get code object from decompiled code. :param list consts: constants to add in the result. :param list intcode: list of byte code to use. :param newcodeobj: new code object with empty body. :param oldcodeobj: old code object. :return: new code object to produce."""


    # get code string
    if PY3:
        codestr = bytes(intcode)

    else:
        codestr = reduce(lambda x, y: x + y, (chr(b) for b in intcode))

    # get vargs
    vargs = [
        newcodeobj.co_argcount, newcodeobj.co_nlocals, newcodeobj.co_stacksize,
        newcodeobj.co_flags, codestr, tuple(consts), newcodeobj.co_names,
        newcodeobj.co_varnames, newcodeobj.co_filename, newcodeobj.co_name,
        newcodeobj.co_firstlineno, newcodeobj.co_lnotab,
        oldcodeobj.co_freevars, newcodeobj.co_cellvars
    ]
    if PY3:
        vargs.insert(1, newcodeobj.co_kwonlyargcount)

    # instanciate a new newcodeobj object
    result = type(newcodeobj)(*vargs)

    return result