# Buggy code
def hosts(self):
    """Generate Iterator over usable hosts in a network.

    This is like __iter__ except it doesn't return the
    Subnet-Router anycast address.

    """
    network = int(self.network_address)
    broadcast = int(self.broadcast_address)
    for x in range(1, broadcast - network + 1):
        yield self._address_class(network + x)


# 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 hosts(self):
    """Generate Iterator over usable hosts in a network.

    This is like __iter__ except it doesn't return the
    Subnet-Router anycast address.

    """
    network = int(self.network_address)
    broadcast = int(self.broadcast_address)
    for x in long_range(1, broadcast - network + 1):
        yield self._address_class(network + x)