# Buggy code
def _publish(
    tgt, fun, arg=None, expr_form="glob", returner="", timeout=5, form="clean"
):
    """
    Publish a command from the minion out to other minions, publications need
    to be enabled on the Salt master and the minion needs to have permission
    to publish the command. The Salt master will also prevent a recursive
    publication loop, this means that a minion cannot command another minion
    to command another minion as that would create an infinite command loop.

    The arguments sent to the minion publish function are separated with
    commas. This means that for a minion executing a command with multiple
    args it will look like this::

        salt system.example.com publish.publish '*' user.add 'foo,1020,1020'

    CLI Example::

        salt system.example.com publish.publish '*' cmd.run 'ls -la /tmp'
    """
    if fun == "publish.publish":
        log.info("Function name is 'publish.publish'. Returning {}")
        # Need to log something here
        return {}
    arg = _normalize_arg(arg)

    log.info("Publishing {0!r} to {master_uri}".format(fun, **__opts__))
    sreq = salt.payload.SREQ(__opts__["master_uri"])
    auth = salt.crypt.SAuth(__opts__)
    tok = auth.gen_token("salt")
    load = {
        "cmd": "minion_pub",
        "fun": fun,
        "arg": arg,
        "tgt": tgt,
        "tgt_type": expr_form,
        "ret": returner,
        "tok": tok,
        "tmo": timeout,
        "form": form,
        "id": __opts__["id"],
    }

    try:
        peer_data = auth.crypticle.loads(
            sreq.send("aes", auth.crypticle.dumps(load), 1)
        )
    except SaltReqTimeoutError:
        return "{0!r} publish timed out".format(fun)
    if not peer_data:
        return {}
    time.sleep(timeout)
    load = {"cmd": "pub_ret", "id": __opts__["id"], "tok": tok, "jid": peer_data["jid"]}
    return auth.crypticle.loads(sreq.send("aes", auth.crypticle.dumps(load), 5))


# 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 265, in run
caller.run()
File "/usr/lib/pymodules/python2.7/salt/cli/caller.py", line 134, in run
ret = self.call()
File "/usr/lib/pymodules/python2.7/salt/cli/caller.py", line 75, in call
ret['return'] = func(*args, **kwargs)
File "/usr/lib/pymodules/python2.7/salt/modules/publish.py", line 129, in publish
return _publish(tgt, fun, arg, expr_form, returner, timeout, 'clean')
File "/usr/lib/pymodules/python2.7/salt/modules/publish.py", line 72, in _publish
time.sleep(timeout)
TypeError: a float is required

# Fixed code
def _publish(
    tgt, fun, arg=None, expr_form="glob", returner="", timeout=5, form="clean"
):
    """
    Publish a command from the minion out to other minions, publications need
    to be enabled on the Salt master and the minion needs to have permission
    to publish the command. The Salt master will also prevent a recursive
    publication loop, this means that a minion cannot command another minion
    to command another minion as that would create an infinite command loop.

    The arguments sent to the minion publish function are separated with
    commas. This means that for a minion executing a command with multiple
    args it will look like this::

        salt system.example.com publish.publish '*' user.add 'foo,1020,1020'

    CLI Example::

        salt system.example.com publish.publish '*' cmd.run 'ls -la /tmp'
    """
    if fun == "publish.publish":
        log.info("Function name is 'publish.publish'. Returning {}")
        # Need to log something here
        return {}
    arg = _normalize_arg(arg)

    log.info("Publishing {0!r} to {master_uri}".format(fun, **__opts__))
    sreq = salt.payload.SREQ(__opts__["master_uri"])
    auth = salt.crypt.SAuth(__opts__)
    tok = auth.gen_token("salt")
    load = {
        "cmd": "minion_pub",
        "fun": fun,
        "arg": arg,
        "tgt": tgt,
        "tgt_type": expr_form,
        "ret": returner,
        "tok": tok,
        "tmo": timeout,
        "form": form,
        "id": __opts__["id"],
    }

    try:
        peer_data = auth.crypticle.loads(
            sreq.send("aes", auth.crypticle.dumps(load), 1)
        )
    except SaltReqTimeoutError:
        return "{0!r} publish timed out".format(fun)
    if not peer_data:
        return {}
    # CLI args are passed as strings, re-cast to keep time.sleep happy
    time.sleep(float(timeout))
    load = {"cmd": "pub_ret", "id": __opts__["id"], "tok": tok, "jid": peer_data["jid"]}
    return auth.crypticle.loads(sreq.send("aes", auth.crypticle.dumps(load), 5))