def replace_default_argument(function, argument, replacement):
    argument_index = find_argument_index(function, argument)
    num_positional_args = (function.func_code.co_argcount -
                         len(function.func_defaults))
    default_position = argument_index - num_positional_args
    if default_position < 0:
        raise ApiSecurityException('Attempt to modify positional default value')
    new_defaults = list(function.func_defaults)
    new_defaults[default_position] = replacement
    function.func_defaults = tuple(new_defaults)


# JSON.
dataset/ETHPy150Open potatolondon/djangae/djangae/contrib/security/middleware.py/replace_default_argument/original