human
Complete this python program:
def binary_replace(data, a, b):
assistant
#Here is the Python code you requested.

    """Perform a binary replacement of `data`, where the placeholder `a` is
    replaced with `b` and the remaining string is padded with null characters.
    All input arguments are expected to be bytes objects.
    """
    if on_win:
        if has_pyzzer_entry_point(data):
            return replace_pyzzer_entry_point_shebang(data, a, b)
        else:
            return data
    def replace(match):
        occurances = match.group().count(a)
        padding = ((len(a) - len(b)) * occurances)
        if (padding < 0):
            raise _PaddingError
        return (match.group().replace(a, b) + ('\x00' * padding))
    original_data_len = len(data)
    pat = re.compile((re.escape(a) + '([^\x00]*?)\x00'))
    data = pat.sub(replace, data)
    assert (len(data) == original_data_len)
    return data