def _unpack_opargs(code, inserted_code_list, current_index):
    """
    Modified version of `_unpack_opargs` function from module `dis`.
    We have to use it, because sometimes code can be in an inconsistent state: if EXTENDED_ARG
    operator was introduced into the code, but it hasn't been inserted into `code_list` yet.
    In this case we can't use standard `_unpack_opargs` and we should check whether there are
    some new operators in `inserted_code_list`.
    """
    extended_arg = 0
    for i in range(0, len(code), 2):
        op = code[i]
        if op >= HAVE_ARGUMENT:
            if not extended_arg:
                # in case if we added EXTENDED_ARG, but haven't inserted it to the source code yet.
                for code_index in range(current_index, len(inserted_code_list)):
                    inserted_offset, inserted_code = inserted_code_list[code_index]
                    if inserted_offset == i and inserted_code[0] == EXTENDED_ARG:
                        extended_arg = inserted_code[1] << 8
            arg = code[i + 1] | extended_arg
            extended_arg = (arg << 8) if op == EXTENDED_ARG else 0
        else:
            arg = None
        yield (i, op, arg)
def _unpack_opargs ( code , inserted_code_list , current_index ) : extended_arg = 0 for i in range ( 0 , len ( code ) , 2 ) : op = code [ i ] if op >= HAVE_ARGUMENT : if not extended_arg : for code_index in range ( current_index , len ( inserted_code_list ) ) : inserted_offset , inserted_code = inserted_code_list [ code_index ] if inserted_offset == i and inserted_code [ 0 ] == EXTENDED_ARG : extended_arg = inserted_code [ 1 ] << 8 arg = code [ i + 1 ] | extended_arg extended_arg = ( arg << 8 ) if op == EXTENDED_ARG else 0 else : arg = None yield ( i , op , arg )
Modified version of `_unpack_opargs` function from module `dis`.
    We have to use it, because sometimes code can be in an inconsistent state: if EXTENDED_ARG
    operator was introduced into the code, but it hasn't been inserted into `code_list` yet.
    In this case we can't use standard `_unpack_opargs` and we should check whether there are
    some new operators in `inserted_code_list`.