# Buggy code
def _repo_process_pkg_sls(filename, short_path_name, ret, successful_verbose):
    renderers = salt.loader.render(__opts__, __salt__)

    def _failed_compile(msg):
        log.error(msg)
        ret.setdefault("errors", {})[short_path_name] = [msg]
        return False

    try:
        config = salt.template.compile_template(
            filename,
            renderers,
            __opts__["renderer"],
            __opts__.get("renderer_blacklist", ""),
            __opts__.get("renderer_whitelist", ""),
        )
    except SaltRenderError as exc:
        msg = "Failed to compile '{0}': {1}".format(short_path_name, exc)
        return _failed_compile(msg)
    except Exception as exc:
        msg = "Failed to read '{0}': {1}".format(short_path_name, exc)
        return _failed_compile(msg)

    if config:
        revmap = {}
        errors = []
        for pkgname, version_list in six.iteritems(config):
            if pkgname in ret["repo"]:
                log.error(
                    "package '%s' within '%s' already defined, skipping",
                    pkgname,
                    short_path_name,
                )
                errors.append("package '{0}' already defined".format(pkgname))
                break
            for version_str, repodata in six.iteritems(version_list):
                # Ensure version is a string/unicode
                if not isinstance(version_str, six.string_types):
                    msg = (
                        "package '{0}'{{0}}, version number {1} is not a string".format(
                            pkgname, version_str
                        )
                    )
                    log.error(msg.format(" within '{0}'".format(short_path_name)))
                    errors.append(msg.format(""))
                    continue
                # Ensure version contains a dict
                if not isinstance(repodata, dict):
                    msg = (
                        "package '{0}'{{0}}, repo data for "
                        "version number {1} is not defined as a dictionary ".format(
                            pkgname, version_str
                        )
                    )
                    log.error(msg.format(" within '{0}'".format(short_path_name)))
                    errors.append(msg.format(""))
                    continue
                revmap[repodata["full_name"]] = pkgname
        if errors:
            ret.setdefault("errors", {})[short_path_name] = errors
        else:
            ret.setdefault("repo", {}).update(config)
            ret.setdefault("name_map", {}).update(revmap)
            successful_verbose[short_path_name] = config.keys()
    else:
        log.debug("No data within '%s' after processing", short_path_name)
        # no pkgname found after render
        successful_verbose[short_path_name] = []


# Traceback (AttributeError)
salt my_win_minion pkg.refresh_db
mywin_minion:
The minion function caused an exception: Traceback (most recent call last):
File "c:\salt\bin\lib\site-packages\salt\minion.py", line 1470, in _thread_return
return_data = executor.execute()
File "c:\salt\bin\lib\site-packages\salt\executors\direct_call.py", line 28, in execute
return self.func(*self.args, **self.kwargs)
File "c:\salt\bin\lib\site-packages\salt\modules\win_pkg.py", line 605, in refresh_db
return genrepo(saltenv=saltenv, verbose=verbose, failhard=failhard)
File "c:\salt\bin\lib\site-packages\salt\modules\win_pkg.py", line 761, in genrepo
successful_verbose
File "c:\salt\bin\lib\site-packages\salt\modules\win_pkg.py", line 829, in _repo_process_pkg_sls
for pkgname, versions in six.iteritems(config):
File "c:\salt\bin\lib\site-packages\salt\ext\six.py", line 606, in iteritems
return d.iteritems(**kw)
AttributeError: 'str' object has no attribute 'iteritems'

# Fixed code
def _repo_process_pkg_sls(filename, short_path_name, ret, successful_verbose):
    renderers = salt.loader.render(__opts__, __salt__)

    def _failed_compile(prefix_msg, error_msg):
        log.error("{0} '{1}': {2} ".format(prefix_msg, short_path_name, error_msg))
        ret.setdefault("errors", {})[short_path_name] = [
            "{0}, {1} ".format(prefix_msg, error_msg)
        ]
        return False

    try:
        config = salt.template.compile_template(
            filename,
            renderers,
            __opts__["renderer"],
            __opts__.get("renderer_blacklist", ""),
            __opts__.get("renderer_whitelist", ""),
        )
    except SaltRenderError as exc:
        return _failed_compile("Failed to compile", exc)
    except Exception as exc:
        return _failed_compile("Failed to read", exc)

    if config and isinstance(config, dict):
        revmap = {}
        errors = []
        for pkgname, version_list in six.iteritems(config):
            if pkgname in ret["repo"]:
                log.error(
                    "package '%s' within '%s' already defined, skipping",
                    pkgname,
                    short_path_name,
                )
                errors.append("package '{0}' already defined".format(pkgname))
                break
            for version_str, repodata in six.iteritems(version_list):
                # Ensure version is a string/unicode
                if not isinstance(version_str, six.string_types):
                    msg = (
                        "package '{0}'{{0}}, version number {1} is not a string".format(
                            pkgname, version_str
                        )
                    )
                    log.error(msg.format(" within '{0}'".format(short_path_name)))
                    errors.append(msg.format(""))
                    continue
                # Ensure version contains a dict
                if not isinstance(repodata, dict):
                    msg = (
                        "package '{0}'{{0}}, repo data for "
                        "version number {1} is not defined as a dictionary ".format(
                            pkgname, version_str
                        )
                    )
                    log.error(msg.format(" within '{0}'".format(short_path_name)))
                    errors.append(msg.format(""))
                    continue
                revmap[repodata["full_name"]] = pkgname
        if errors:
            ret.setdefault("errors", {})[short_path_name] = errors
        else:
            ret.setdefault("repo", {}).update(config)
            ret.setdefault("name_map", {}).update(revmap)
            successful_verbose[short_path_name] = config.keys()
    elif config:
        return _failed_compile("Compiled contents", "not a dictionary/hash")
    else:
        log.debug("No data within '%s' after processing", short_path_name)
        # no pkgname found after render
        successful_verbose[short_path_name] = []