# Buggy code
def __gen_opts(self, opts):
    """
    The options used by the High State object are derived from options
    on the minion and the master, or just the minion if the high state
    call is entirely local.
    """
    # If the state is intended to be applied locally, then the local opts
    # should have all of the needed data, otherwise overwrite the local
    # data items with data from the master
    if "local_state" in opts:
        if opts["local_state"]:
            return opts
    mopts = self.client.master_opts()
    if not isinstance(mopts, dict):
        # An error happened on the master
        opts["renderer"] = "yaml_jinja"
        opts["failhard"] = False
        opts["state_top"] = "salt://top.sls"
        opts["nodegroups"] = {}
        opts["file_roots"] = {"base": ["/srv/salt"]}
    opts["renderer"] = mopts["renderer"]
    opts["failhard"] = mopts.get("failhard", False)
    if mopts["state_top"].startswith("salt://"):
        opts["state_top"] = mopts["state_top"]
    elif mopts["state_top"].startswith("/"):
        opts["state_top"] = os.path.join("salt://", mopts["state_top"][1:])
    else:
        opts["state_top"] = os.path.join("salt://", mopts["state_top"])
    opts["nodegroups"] = mopts.get("nodegroups", {})
    opts["file_roots"] = mopts["file_roots"]
    return opts


# Traceback (TypeError)
Traceback (most recent call last):
File "/usr/bin/salt-call", line 11, in <module>
salt_call()
File "/usr/lib/pymodules/python2.7/salt/scripts.py", line 76, in salt_call
client.run()
File "/usr/lib/pymodules/python2.7/salt/cli/__init__.py", line 257, in run
caller.run()
File "/usr/lib/pymodules/python2.7/salt/cli/caller.py", line 163, in run
ret = self.call()
File "/usr/lib/pymodules/python2.7/salt/cli/caller.py", line 76, in call
ret['return'] = func(*args, **kwargs)
File "/usr/lib/pymodules/python2.7/salt/modules/state.py", line 195, in highstate
st_ = salt.state.HighState(opts, pillar)
File "/usr/lib/pymodules/python2.7/salt/state.py", line 2144, in __init__
BaseHighState.__init__(self, opts)
File "/usr/lib/pymodules/python2.7/salt/state.py", line 1523, in __init__
self.opts = self.__gen_opts(opts)
File "/usr/lib/pymodules/python2.7/salt/state.py", line 1550, in __gen_opts
opts['renderer'] = mopts['renderer']
TypeError: string indices must be integers, not str

# Fixed code
def __gen_opts(self, opts):
    """
    The options used by the High State object are derived from options
    on the minion and the master, or just the minion if the high state
    call is entirely local.
    """
    # If the state is intended to be applied locally, then the local opts
    # should have all of the needed data, otherwise overwrite the local
    # data items with data from the master
    if "local_state" in opts:
        if opts["local_state"]:
            return opts
    mopts = self.client.master_opts()
    if not isinstance(mopts, dict):
        # An error happened on the master
        opts["renderer"] = "yaml_jinja"
        opts["failhard"] = False
        opts["state_top"] = "salt://top.sls"
        opts["nodegroups"] = {}
        opts["file_roots"] = {"base": ["/srv/salt"]}
    else:
        opts["renderer"] = mopts["renderer"]
        opts["failhard"] = mopts.get("failhard", False)
        if mopts["state_top"].startswith("salt://"):
            opts["state_top"] = mopts["state_top"]
        elif mopts["state_top"].startswith("/"):
            opts["state_top"] = os.path.join("salt://", mopts["state_top"][1:])
        else:
            opts["state_top"] = os.path.join("salt://", mopts["state_top"])
        opts["nodegroups"] = mopts.get("nodegroups", {})
        opts["file_roots"] = mopts["file_roots"]
    return opts