在使用IPv6时,我注意到netaddr中的IPRange的cidrs()方法存在问题。
如果我定义较小的IPv6范围,它可以正常工作:
r1=IPRange('1fe::2','1fe::100')
r1.cidrs()
[IPNetwork('1fe::2/127'), IPNetwork('1fe::4/126'), IPNetwork('1fe::8/125'), IPNetwork('1fe::10/124'), IPNetwork('1fe::20/123'), IPNetwork('1fe::40/122'), IPNetwork('1fe::80/121'), IPNetwork('1fe::100/128')]
如果我定义一个大范围集,我会收到一个追溯:
r1=IPRange('1fe::2','2fe::1')
r1.cidrs()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/netaddr/ip/__init__.py", line 1337,
in cidrs
return iprange_to_cidrs(self._start, self._end)
File "/usr/lib/python2.7/dist-packages/netaddr/ip/__init__.py", line 1798,
in iprange_to_cidrs
cidr_remainder = cidr_exclude(cidr_list.pop(), ip)
IndexError: pop from empty list
有人知道这是cidrs()中的限制还是错误?