# Buggy code
def parse_inventory(self, host_list):
    if isinstance(host_list, string_types):
        if "," in host_list:
            host_list = host_list.split(",")
            host_list = [h for h in host_list if h and h.strip()]

    self.parser = None

    # Always create the 'all' and 'ungrouped' groups, even if host_list is
    # empty: in this case we will subsequently an the implicit 'localhost' to it.

    ungrouped = Group(name="ungrouped")
    all = Group("all")
    all.add_child_group(ungrouped)

    self.groups = dict(all=all, ungrouped=ungrouped)

    if host_list is None:
        pass
    elif isinstance(host_list, list):
        for h in host_list:
            (host, port) = parse_address(h, allow_ranges=False)
            all.add_host(Host(host, port))
    elif self._loader.path_exists(host_list):
        # TODO: switch this to a plugin loader and a 'condition' per plugin on which it should be tried, restoring 'inventory pllugins'
        if self.is_directory(host_list):
            # Ensure basedir is inside the directory
            host_list = os.path.join(self.host_list, "")
            self.parser = InventoryDirectory(
                loader=self._loader, groups=self.groups, filename=host_list
            )
        else:
            self.parser = get_file_parser(host_list, self.groups, self._loader)
            vars_loader.add_directory(self.basedir(), with_subdir=True)

        if not self.parser:
            # should never happen, but JIC
            raise AnsibleError("Unable to parse %s as an inventory source" % host_list)

    self._vars_plugins = [x for x in vars_loader.all(self)]

    # get group vars from group_vars/ files and vars plugins
    for group in self.groups.values():
        group.vars = combine_vars(group.vars, self.get_group_variables(group.name))

    # get host vars from host_vars/ files and vars plugins
    for host in self.get_hosts():
        host.vars = combine_vars(host.vars, self.get_host_variables(host.name))


# Traceback (AttributeError)
$ ansible -vvv all -c guestfs -i 'Fedora-Cloud-Atomic-23-20151215.x86_64.qcow2:/dev/sda1,'  -m ping
Using /home/misc/.ansible.cfg as config file
Unexpected Exception: 'NoneType' object has no attribute 'split'
the full traceback was:

Traceback (most recent call last):
File "/home/misc/checkout/git/ansible/bin/ansible", line 85, in <module>
sys.exit(cli.run())
File "/home/misc/checkout/git/ansible/lib/ansible/cli/adhoc.py", line 187, in run
result = self._tqm.run(play)
File "/home/misc/checkout/git/ansible/lib/ansible/executor/task_queue_manager.py", line 237, in run
play_return = strategy.run(iterator, play_context)
File "/home/misc/checkout/git/ansible/lib/ansible/plugins/strategy/linear.py", line 217, in run
task_vars = self._variable_manager.get_vars(loader=self._loader, play=iterator._play, host=host, task=task)
File "/home/misc/checkout/git/ansible/lib/ansible/vars/__init__.py", line 245, in get_vars
all_vars = combine_vars(all_vars, host.get_vars())
File "/home/misc/checkout/git/ansible/lib/ansible/inventory/host.py", line 129, in get_vars
results['inventory_hostname_short'] = self.name.split('.')[0]
AttributeError: 'NoneType' object has no attribute 'split'

# Fixed code
def parse_inventory(self, host_list):
    if isinstance(host_list, string_types):
        if "," in host_list:
            host_list = host_list.split(",")
            host_list = [h for h in host_list if h and h.strip()]

    self.parser = None

    # Always create the 'all' and 'ungrouped' groups, even if host_list is
    # empty: in this case we will subsequently an the implicit 'localhost' to it.

    ungrouped = Group(name="ungrouped")
    all = Group("all")
    all.add_child_group(ungrouped)

    self.groups = dict(all=all, ungrouped=ungrouped)

    if host_list is None:
        pass
    elif isinstance(host_list, list):
        for h in host_list:
            try:
                (host, port) = parse_address(h, allow_ranges=False)
            except AnsibleError as e:
                display.vvv(
                    "Unable to parse address from hostname, leaving unchanged: %s"
                    % to_string(e)
                )
                host = h
                port = None
            all.add_host(Host(host, port))
    elif self._loader.path_exists(host_list):
        # TODO: switch this to a plugin loader and a 'condition' per plugin on which it should be tried, restoring 'inventory pllugins'
        if self.is_directory(host_list):
            # Ensure basedir is inside the directory
            host_list = os.path.join(self.host_list, "")
            self.parser = InventoryDirectory(
                loader=self._loader, groups=self.groups, filename=host_list
            )
        else:
            self.parser = get_file_parser(host_list, self.groups, self._loader)
            vars_loader.add_directory(self.basedir(), with_subdir=True)

        if not self.parser:
            # should never happen, but JIC
            raise AnsibleError("Unable to parse %s as an inventory source" % host_list)

    self._vars_plugins = [x for x in vars_loader.all(self)]

    # get group vars from group_vars/ files and vars plugins
    for group in self.groups.values():
        group.vars = combine_vars(group.vars, self.get_group_variables(group.name))

    # get host vars from host_vars/ files and vars plugins
    for host in self.get_hosts():
        host.vars = combine_vars(host.vars, self.get_host_variables(host.name))