def _format_arg(self, arg):
        if IS_PY3:
            arg = str(arg)
        else:
            try:
                arg = unicode(arg, DEFAULT_ENCODING).encode(DEFAULT_ENCODING)
            except __HOLE__:
                arg = unicode(arg).encode(DEFAULT_ENCODING)

        if self._partial:
            escaped = arg.replace('"', '\\"')
            escaped = escaped.replace("$", "\$")
            escaped = escaped.replace("`", "\`")

            arg = '"{0}"'.format(escaped)

        return arg
dataset/ETHPy150Open chrippa/livestreamer/src/livestreamer/packages/pbs.py/Command._format_arg