human
Complete this python program:
def convert_command_args(args):
assistant
#Here is the Python code you requested.

    """Convert command arguments to bytestrings on Python 2 and
    surrogate-escaped strings on Python 3.
    """
    assert isinstance(args, list)
    def convert(arg):
        if six.PY2:
            if isinstance(arg, six.text_type):
                arg = arg.encode(arg_encoding())
        elif isinstance(arg, bytes):
            arg = arg.decode(arg_encoding(), 'surrogateescape')
        return arg
    return [convert(a) for a in args]