# Buggy code
def run(self):
    super(ConfigCLI, self).run()

    if self.options.config_file:
        self.config_file = unfrackpath(self.options.config_file, follow=False)
        self.config = ConfigManager(self.config_file)
    else:
        self.config = ConfigManager()
        self.config_file = find_ini_config_file()
    try:
        if not os.path.exists(self.config_file):
            raise AnsibleOptionsError(
                "%s does not exist or is not accessible" % (self.config_file)
            )
        elif not os.path.isfile(self.config_file):
            raise AnsibleOptionsError("%s is not a valid file" % (self.config_file))

        os.environ["ANSIBLE_CONFIG"] = to_native(self.config_file)
    except:
        if self.action in ["view"]:
            raise
        elif self.action in ["edit", "update"]:
            display.warning(
                "File does not exist, used empty file: %s" % self.config_file
            )

    self.execute()


# Traceback (TypeError)
[newswoop:F27:~]$ ansible-config view -vvv
ansible-config 2.5.0b1
config file = None
configured module search path = ['/home/adrian/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/adrian/.local/lib/python3.6/site-packages/ansible
executable location = /home/adrian/.local/bin/ansible-config
python version = 3.6.4 (default, Jan 23 2018, 22:28:37) [GCC 7.2.1 20170915 (Red Hat 7.2.1-2)]
No config file found; using defaults
ERROR! Unexpected Exception, this is probably a bug: stat: path should be string, bytes, os.PathLike or integer, not NoneType
the full traceback was:

Traceback (most recent call last):
File "/home/adrian/.local/bin/ansible-config", line 118, in <module>
exit_code = cli.run()
File "/home/adrian/.local/lib/python3.6/site-packages/ansible/cli/config.py", line 77, in run
if not os.path.exists(self.config_file):
File "/usr/lib64/python3.6/genericpath.py", line 19, in exists
os.stat(path)
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType

# Fixed code
def run(self):
    super(ConfigCLI, self).run()

    if self.options.config_file:
        self.config_file = unfrackpath(self.options.config_file, follow=False)
        self.config = ConfigManager(self.config_file)
    else:
        self.config = ConfigManager()
        self.config_file = find_ini_config_file()

    if self.config_file:
        try:
            if not os.path.exists(self.config_file):
                raise AnsibleOptionsError(
                    "%s does not exist or is not accessible" % (self.config_file)
                )
            elif not os.path.isfile(self.config_file):
                raise AnsibleOptionsError("%s is not a valid file" % (self.config_file))

            os.environ["ANSIBLE_CONFIG"] = to_native(self.config_file)
        except:
            if self.action in ["view"]:
                raise
            elif self.action in ["edit", "update"]:
                display.warning(
                    "File does not exist, used empty file: %s" % self.config_file
                )

    elif self.action == "view":
        raise AnsibleError("Invalid or no config file was supplied")

    self.execute()