# Buggy code
def split_host_pattern(cls, pattern):
    """
    Takes a string containing host patterns separated by commas (or a list
    thereof) and returns a list of single patterns (which may not contain
    commas). Whitespace is ignored.

    Also accepts ':' as a separator for backwards compatibility, but it is
    not recommended due to the conflict with IPv6 addresses and host ranges.

    Example: 'a,b[1], c[2:3] , d' -> ['a', 'b[1]', 'c[2:3]', 'd']
    """

    if isinstance(pattern, list):
        return list(itertools.chain(*map(cls.split_host_pattern, pattern)))

    if ";" in pattern:
        patterns = re.split("\s*;\s*", pattern)
        display.deprecated("Use ',' or ':' instead of ';' to separate host patterns")

    # If it's got commas in it, we'll treat it as a straightforward
    # comma-separated list of patterns.

    elif "," in pattern:
        patterns = re.split("\s*,\s*", pattern)

    # If it doesn't, it could still be a single pattern. This accounts for
    # non-separator uses of colons: IPv6 addresses and [x:y] host ranges.
    else:
        (base, port) = parse_address(pattern, allow_ranges=True)
        if base:
            patterns = [pattern]

        # The only other case we accept is a ':'-separated list of patterns.
        # This mishandles IPv6 addresses, and is retained only for backwards
        # compatibility.

        else:
            patterns = re.findall(
                r"""(?:             # We want to match something comprising:
                            [^\s:\[\]]  # (anything other than whitespace or ':[]'
                            |           # ...or...
                            \[[^\]]*\]  # a single complete bracketed expression)
                        )+              # occurring once or more
                    """,
                pattern,
                re.X,
            )

    return [p.strip() for p in patterns]


# 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 split_host_pattern(cls, pattern):
    """
    Takes a string containing host patterns separated by commas (or a list
    thereof) and returns a list of single patterns (which may not contain
    commas). Whitespace is ignored.

    Also accepts ':' as a separator for backwards compatibility, but it is
    not recommended due to the conflict with IPv6 addresses and host ranges.

    Example: 'a,b[1], c[2:3] , d' -> ['a', 'b[1]', 'c[2:3]', 'd']
    """

    if isinstance(pattern, list):
        return list(itertools.chain(*map(cls.split_host_pattern, pattern)))

    if ";" in pattern:
        patterns = re.split("\s*;\s*", pattern)
        display.deprecated("Use ',' or ':' instead of ';' to separate host patterns")

    # If it's got commas in it, we'll treat it as a straightforward
    # comma-separated list of patterns.

    elif "," in pattern:
        patterns = re.split("\s*,\s*", pattern)

    # If it doesn't, it could still be a single pattern. This accounts for
    # non-separator uses of colons: IPv6 addresses and [x:y] host ranges.
    else:
        try:
            (base, port) = parse_address(pattern, allow_ranges=True)
            patterns = [pattern]
        except:
            # The only other case we accept is a ':'-separated list of patterns.
            # This mishandles IPv6 addresses, and is retained only for backwards
            # compatibility.
            patterns = re.findall(
                r"""(?:             # We want to match something comprising:
                            [^\s:\[\]]  # (anything other than whitespace or ':[]'
                            |           # ...or...
                            \[[^\]]*\]  # a single complete bracketed expression)
                        )+              # occurring once or more
                    """,
                pattern,
                re.X,
            )

    return [p.strip() for p in patterns]