# Buggy code
def network_hosts(value, options=None, version=None):
    """
    Return the list of hosts within a network.
    """
    ipaddr_filter_out = _filter_ipaddr(value, options=options, version=version)
    if not ipaddr_filter_out:
        return
    if not isinstance(value, (list, tuple, types.GeneratorType)):
        return _network_hosts(ipaddr_filter_out[0])
    return [_network_hosts(ip_a) for ip_a in ipaddr_filter_out]


# Traceback (OverflowError)
[ERROR   ] Rendering exception occurred: Jinja error: Python int too large to convert to C long
Traceback (most recent call last):
File "/opt/local/lib/python2.7/site-packages/salt/utils/templates.py", line 410, in render_jinja_tmpl
output = template.render(**decoded_context)
File "/opt/local/lib/python2.7/site-packages/jinja2/environment.py", line 989, in render
return self.environment.handle_exception(exc_info, True)
File "/opt/local/lib/python2.7/site-packages/jinja2/environment.py", line 754, in handle_exception
reraise(exc_type, exc_value, tb)
File "<template>", line 3, in top-level template code
File "/opt/local/lib/python2.7/site-packages/salt/utils/network.py", line 461, in network_hosts
return _network_hosts(ipaddr_filter_out[0])
File "/opt/local/lib/python2.7/site-packages/salt/utils/network.py", line 449, in _network_hosts
for host in ipaddress.ip_network(ip_addr_entry, strict=False).hosts()
File "/opt/local/lib/python2.7/site-packages/salt/ext/ipaddress.py", line 2262, in hosts
for x in range(1, broadcast - network + 1):
OverflowError: Python int too large to convert to C long

; line 3

---
/tmp/test:
file.managed:
- contents: {{ '2001:470:7ee7:30::/64' | network_hosts }}    <======================

Traceback (most recent call last):
File "/opt/local/lib/python2.7/site-packages/salt/utils/templates.py", line 410, in render_jinja_tmpl
output = template.render(**decoded_context)
File "/opt/local/lib/python2.7/site-packages/jinja2/environment.py", line 989, in render
[...]
---
[CRITICAL] Rendering SLS 'base:test' failed: Jinja error: Python int too large to convert to C long
Traceback (most recent call last):
File "/opt/local/lib/python2.7/site-packages/salt/utils/templates.py", line 410, in render_jinja_tmpl
output = template.render(**decoded_context)
File "/opt/local/lib/python2.7/site-packages/jinja2/environment.py", line 989, in render
return self.environment.handle_exception(exc_info, True)
File "/opt/local/lib/python2.7/site-packages/jinja2/environment.py", line 754, in handle_exception
reraise(exc_type, exc_value, tb)
File "<template>", line 3, in top-level template code
File "/opt/local/lib/python2.7/site-packages/salt/utils/network.py", line 461, in network_hosts
return _network_hosts(ipaddr_filter_out[0])
File "/opt/local/lib/python2.7/site-packages/salt/utils/network.py", line 449, in _network_hosts
for host in ipaddress.ip_network(ip_addr_entry, strict=False).hosts()
File "/opt/local/lib/python2.7/site-packages/salt/ext/ipaddress.py", line 2262, in hosts
for x in range(1, broadcast - network + 1):
OverflowError: Python int too large to convert to C long

; line 3

---
/tmp/test:
file.managed:
- contents: {{ '2001:470:7ee7:30::/64' | network_hosts }}    <======================

Traceback (most recent call last):
File "/opt/local/lib/python2.7/site-packages/salt/utils/templates.py", line 410, in render_jinja_tmpl
output = template.render(**decoded_context)
File "/opt/local/lib/python2.7/site-packages/jinja2/environment.py", line 989, in render
[...]
---
local:
Data failed to compile:
----------
Rendering SLS 'base:test' failed: Jinja error: Python int too large to convert to C long
Traceback (most recent call last):
File "/opt/local/lib/python2.7/site-packages/salt/utils/templates.py", line 410, in render_jinja_tmpl
output = template.render(**decoded_context)
File "/opt/local/lib/python2.7/site-packages/jinja2/environment.py", line 989, in render
return self.environment.handle_exception(exc_info, True)
File "/opt/local/lib/python2.7/site-packages/jinja2/environment.py", line 754, in handle_exception
reraise(exc_type, exc_value, tb)
File "<template>", line 3, in top-level template code
File "/opt/local/lib/python2.7/site-packages/salt/utils/network.py", line 461, in network_hosts
return _network_hosts(ipaddr_filter_out[0])
File "/opt/local/lib/python2.7/site-packages/salt/utils/network.py", line 449, in _network_hosts
for host in ipaddress.ip_network(ip_addr_entry, strict=False).hosts()
File "/opt/local/lib/python2.7/site-packages/salt/ext/ipaddress.py", line 2262, in hosts
for x in range(1, broadcast - network + 1):
OverflowError: Python int too large to convert to C long

; line 3

---
/tmp/test:
file.managed:
- contents: {{ '2001:470:7ee7:30::/64' | network_hosts }}    <======================

Traceback (most recent call last):
File "/opt/local/lib/python2.7/site-packages/salt/utils/templates.py", line 410, in render_jinja_tmpl
output = template.render(**decoded_context)
File "/opt/local/lib/python2.7/site-packages/jinja2/environment.py", line 989, in render
[...]
---

# Fixed code
def network_hosts(value, options=None, version=None):
    """
    Return the list of hosts within a network.

    .. note::

        When running this command with a large IPv6 network, the command will
        take a long time to gather all of the hosts.
    """
    ipaddr_filter_out = _filter_ipaddr(value, options=options, version=version)
    if not ipaddr_filter_out:
        return
    if not isinstance(value, (list, tuple, types.GeneratorType)):
        return _network_hosts(ipaddr_filter_out[0])
    return [_network_hosts(ip_a) for ip_a in ipaddr_filter_out]