# Buggy code
def run(self):
    """Run the ansible command

    Subclasses must implement this method.  It does the actual work of
    running an Ansible command.
    """

    display.vv(to_text(self.parser.get_version()))

    if C.CONFIG_FILE:
        display.v("Using %s as config file" % to_text(C.CONFIG_FILE))
    else:
        display.v("No config file found; using defaults")

    # warn about deprecated config options
    for deprecated in C.config.DEPRECATED:
        name = deprecated[0]
        why = deprecated[1]["why"]
        if "alternatives" in deprecated[1]:
            alt = ", use %s instead" % deprecated[1]["alternatives"]
        else:
            alt = ""
        ver = deprecated[1]["version"]
        display.deprecated("%s option, %s %s" % (name, why, alt), version=ver)

    # warn about typing issues with configuration entries
    for unable in C.config.UNABLE:
        display.warning(
            "Unable to set correct type for configuration entry: %s" % unable
        )


# Traceback (OptionValueError)
[fedora-25:ansible (devel % u=)]$ ANSIBLE_TIMEOUT= ansible -vvv localhost -m ping
ERROR! Unexpected Exception: option --timeout: invalid integer value: u''
the full traceback was:

Traceback (most recent call last):
File "/home/adrian/src/ansible/bin/ansible", line 102, in <module>
cli.parse()
File "/home/adrian/src/ansible/lib/ansible/cli/adhoc.py", line 75, in parse
super(AdHocCLI, self).parse()
File "/home/adrian/src/ansible/lib/ansible/cli/__init__.py", line 438, in parse
self.options, self.args = self.parser.parse_args(self.args[1:])
File "/usr/lib64/python2.7/optparse.py", line 1384, in parse_args
values = self.get_default_values()
File "/usr/lib64/python2.7/optparse.py", line 1329, in get_default_values
defaults[option.dest] = option.check_value(opt_str, default)
File "/usr/lib64/python2.7/optparse.py", line 770, in check_value
return checker(self, opt, value)
File "/usr/lib64/python2.7/optparse.py", line 430, in check_builtin
_("option %s: invalid %s value: %r") % (opt, what, value))
OptionValueError: option --timeout: invalid integer value: u''

# Fixed code
def run(self):
    """Run the ansible command

    Subclasses must implement this method.  It does the actual work of
    running an Ansible command.
    """

    display.vv(to_text(self.parser.get_version()))

    if C.CONFIG_FILE:
        display.v("Using %s as config file" % to_text(C.CONFIG_FILE))
    else:
        display.v("No config file found; using defaults")

    # warn about deprecated config options
    for deprecated in C.config.DEPRECATED:
        name = deprecated[0]
        why = deprecated[1]["why"]
        if "alternatives" in deprecated[1]:
            alt = ", use %s instead" % deprecated[1]["alternatives"]
        else:
            alt = ""
        ver = deprecated[1]["version"]
        display.deprecated("%s option, %s %s" % (name, why, alt), version=ver)

    # Errors with configuration entries
    if C.config.UNABLE:
        for unable in C.config.UNABLE:
            display.error(
                "Unable to set correct type for configuration entry for %s: %s"
                % (unable, C.config.UNABLE[unable])
            )
        raise AnsibleError("Invalid configuration settings")