# Buggy code
def _return_formatted(self, kwargs):
    self.add_path_info(kwargs)

    if "invocation" not in kwargs:
        kwargs["invocation"] = {"module_args": self.params}

    if "warnings" in kwargs:
        if isinstance(kwargs["warnings"], list):
            for w in kwargs["warnings"]:
                self.warn(w)
        else:
            self.warn(kwargs["warnings"])

    if self._warnings:
        kwargs["warnings"] = self._warnings

    if "deprecations" in kwargs:
        if isinstance(kwargs["deprecations"], list):
            for d in kwargs["deprecations"]:
                if isinstance(d, SEQUENCETYPE) and len(d) == 2:
                    self.deprecate(d[0], version=d[1])
                else:
                    self.deprecate(d)
        else:
            self.deprecate(kwargs["deprecations"])

    if self._deprecations:
        kwargs["deprecations"] = self._deprecations

    kwargs = remove_values(kwargs, self.no_log_values)
    print("\n%s" % self.jsonify(kwargs))


# Traceback (TypeError)
TASK [Get the status of the job] ***************************************************************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: deprecate requires a string not a <type 'dict'>
fatal: [localhost]: FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):
File \"/home/zim/.ansible/tmp/ansible-tmp-1535331789.16-166798681023581/AnsiballZ_async_status.py\", line 113, in <module>
_ansiballz_main()
File \"/home/zim/.ansible/tmp/ansible-tmp-1535331789.16-166798681023581/AnsiballZ_async_status.py\", line 105, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File \"/home/zim/.ansible/tmp/ansible-tmp-1535331789.16-166798681023581/AnsiballZ_async_status.py\", line 48, in invoke_module
imp.load_module('__main__', mod, module, MOD_DESC)
File \"/tmp/ansible_async_status_payload_LzN9Fd/__main__.py\", line 101, in <module>
File \"/tmp/ansible_async_status_payload_LzN9Fd/__main__.py\", line 97, in main
File \"/tmp/ansible_async_status_payload_LzN9Fd/ansible_async_status_payload.zip/ansible/module_utils/basic.py\", line 2339, in exit_json
File \"/tmp/ansible_async_status_payload_LzN9Fd/ansible_async_status_payload.zip/ansible/module_utils/basic.py\", line 2325, in _return_formatted
File \"/tmp/ansible_async_status_payload_LzN9Fd/ansible_async_status_payload.zip/ansible/module_utils/basic.py\", line 961, in deprecate
TypeError: deprecate requires a string not a <type 'dict'>
",
"module_stdout": "",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
}
to retry, use: --limit @/mnt/c/dev-current/openshift-container-platform/ansible/playbooks/create.retry

# Fixed code
def _return_formatted(self, kwargs):
    self.add_path_info(kwargs)

    if "invocation" not in kwargs:
        kwargs["invocation"] = {"module_args": self.params}

    if "warnings" in kwargs:
        if isinstance(kwargs["warnings"], list):
            for w in kwargs["warnings"]:
                self.warn(w)
        else:
            self.warn(kwargs["warnings"])

    if self._warnings:
        kwargs["warnings"] = self._warnings

    if "deprecations" in kwargs:
        if isinstance(kwargs["deprecations"], list):
            for d in kwargs["deprecations"]:
                if isinstance(d, SEQUENCETYPE) and len(d) == 2:
                    self.deprecate(d[0], version=d[1])
                elif isinstance(d, Mapping):
                    self.deprecate(d["msg"], version=d.get("version", None))
                else:
                    self.deprecate(d)
        else:
            self.deprecate(kwargs["deprecations"])

    if self._deprecations:
        kwargs["deprecations"] = self._deprecations

    kwargs = remove_values(kwargs, self.no_log_values)
    print("\n%s" % self.jsonify(kwargs))