# Buggy code
def __init__(self, shell, arguments=None):
    self.shell = shell
    self._raw_arguments = arguments

    if shell == "posix":
        self.pathsep_join = ":".join
        self.path_conversion = native_path_to_unix
        self.script_extension = ".sh"
        self.tempfile_extension = (
            None  # write instructions to stdout rather than a temp file
        )
        self.shift_args = 0
        self.command_join = "\n"

        self.unset_var_tmpl = "unset %s"
        self.export_var_tmpl = "export %s='%s'"
        self.set_var_tmpl = "%s='%s'"
        self.run_script_tmpl = '. "%s"'

    elif shell == "csh":
        self.pathsep_join = ":".join
        self.path_conversion = native_path_to_unix
        self.script_extension = ".csh"
        self.tempfile_extension = (
            None  # write instructions to stdout rather than a temp file
        )
        self.shift_args = 0
        self.command_join = ";\n"

        self.unset_var_tmpl = "unset %s"
        self.export_var_tmpl = 'setenv %s "%s"'
        self.set_var_tmpl = "set %s='%s'"
        self.run_script_tmpl = 'source "%s"'

    elif shell == "xonsh":
        self.pathsep_join = ":".join
        self.path_conversion = native_path_to_unix
        self.script_extension = ".xsh"
        self.tempfile_extension = ".xsh"
        self.shift_args = 0
        self.command_join = "\n"

        self.unset_var_tmpl = "del $%s"
        self.export_var_tmpl = "$%s = '%s'"
        self.run_script_tmpl = 'source "%s"'

    elif shell == "cmd.exe":
        self.pathsep_join = ";".join
        self.path_conversion = path_identity
        self.script_extension = ".bat"
        self.tempfile_extension = ".bat"
        self.shift_args = 1
        self.command_join = "\n"

        self.unset_var_tmpl = "@SET %s="
        self.export_var_tmpl = '@SET "%s=%s"'
        self.run_script_tmpl = '@CALL "%s"'

    elif shell == "fish":
        self.pathsep_join = '" "'.join
        self.path_conversion = native_path_to_unix
        self.script_extension = ".fish"
        self.tempfile_extension = (
            None  # write instructions to stdout rather than a temp file
        )
        self.shift_args = 0
        self.command_join = ";\n"

        self.unset_var_tmpl = "set -e %s"
        self.export_var_tmpl = 'set -gx %s "%s"'
        self.run_script_tmpl = 'source "%s"'

    elif shell == "powershell":
        self.pathsep_join = ";".join
        self.path_conversion = path_identity
        self.script_extension = ".ps1"
        self.tempfile_extension = (
            None  # write instructions to stdout rather than a temp file
        )
        self.shift_args = 0
        self.command_join = "\n"

        self.unset_var_tmpl = "Remove-Variable %s"
        self.export_var_tmpl = '$env:%s = "%s"'
        self.run_script_tmpl = '. "%s"'

    else:
        raise NotImplementedError()


# Traceback (ValueError)
Traceback (most recent call last):
File "/anaconda/lib/python2.7/site-packages/conda/gateways/logging.py", line 64, in emit
msg = self.format(record)
File "/anaconda/lib/python2.7/logging/__init__.py", line 734, in format
return fmt.format(record)
File "/anaconda/lib/python2.7/logging/__init__.py", line 465, in format
record.message = record.getMessage()
File "/anaconda/lib/python2.7/logging/__init__.py", line 329, in getMessage
msg = msg % self.args
File "/anaconda/lib/python2.7/site-packages/conda/__init__.py", line 43, in __repr__
return '%s: %s' % (self.__class__.__name__, text_type(self))
File "/anaconda/lib/python2.7/site-packages/conda/__init__.py", line 47, in __str__
return text_type(self.message % self._kwargs)
ValueError: unsupported format character '{' (0x7b) at index 513
Logged from file exceptions.py, line 724

# Fixed code
def __init__(self, shell, arguments=None):
    self.shell = shell
    self._raw_arguments = arguments

    if PY2:
        self.environ = {
            ensure_fs_path_encoding(k): ensure_fs_path_encoding(v)
            for k, v in iteritems(os.environ)
        }
    else:
        self.environ = os.environ.copy()

    if shell == "posix":
        self.pathsep_join = ":".join
        self.path_conversion = native_path_to_unix
        self.script_extension = ".sh"
        self.tempfile_extension = (
            None  # write instructions to stdout rather than a temp file
        )
        self.shift_args = 0
        self.command_join = "\n"

        self.unset_var_tmpl = "unset %s"
        self.export_var_tmpl = "export %s='%s'"
        self.set_var_tmpl = "%s='%s'"
        self.run_script_tmpl = '. "%s"'

    elif shell == "csh":
        self.pathsep_join = ":".join
        self.path_conversion = native_path_to_unix
        self.script_extension = ".csh"
        self.tempfile_extension = (
            None  # write instructions to stdout rather than a temp file
        )
        self.shift_args = 0
        self.command_join = ";\n"

        self.unset_var_tmpl = "unset %s"
        self.export_var_tmpl = 'setenv %s "%s"'
        self.set_var_tmpl = "set %s='%s'"
        self.run_script_tmpl = 'source "%s"'

    elif shell == "xonsh":
        self.pathsep_join = ":".join
        self.path_conversion = native_path_to_unix
        self.script_extension = ".xsh"
        self.tempfile_extension = ".xsh"
        self.shift_args = 0
        self.command_join = "\n"

        self.unset_var_tmpl = "del $%s"
        self.export_var_tmpl = "$%s = '%s'"
        self.run_script_tmpl = 'source "%s"'

    elif shell == "cmd.exe":
        self.pathsep_join = ";".join
        self.path_conversion = path_identity
        self.script_extension = ".bat"
        self.tempfile_extension = ".bat"
        self.shift_args = 1
        self.command_join = "\n"

        self.unset_var_tmpl = "@SET %s="
        self.export_var_tmpl = '@SET "%s=%s"'
        self.run_script_tmpl = '@CALL "%s"'

    elif shell == "fish":
        self.pathsep_join = '" "'.join
        self.path_conversion = native_path_to_unix
        self.script_extension = ".fish"
        self.tempfile_extension = (
            None  # write instructions to stdout rather than a temp file
        )
        self.shift_args = 0
        self.command_join = ";\n"

        self.unset_var_tmpl = "set -e %s"
        self.export_var_tmpl = 'set -gx %s "%s"'
        self.run_script_tmpl = 'source "%s"'

    elif shell == "powershell":
        self.pathsep_join = ";".join
        self.path_conversion = path_identity
        self.script_extension = ".ps1"
        self.tempfile_extension = (
            None  # write instructions to stdout rather than a temp file
        )
        self.shift_args = 0
        self.command_join = "\n"

        self.unset_var_tmpl = "Remove-Variable %s"
        self.export_var_tmpl = '$env:%s = "%s"'
        self.run_script_tmpl = '. "%s"'

    else:
        raise NotImplementedError()