9
9
__version__ = '1.00'
10
10
11
11
import bisect
12
- import collections
12
+ import sys
13
13
import types
14
+ try :
15
+ import collections .abc as collections_abc
16
+ except ImportError :
17
+ import collections as collections_abc
14
18
15
19
# Definition of the Ranges for IPv4 IPs
16
20
# this should include www.iana.org/assignments/ipv4-address-space
@@ -370,6 +374,9 @@ def strCompressed(self, wantprefixlen = None):
370
374
'ffff:ffff:ffff:ffff:ffff:f:f:fffc/127'
371
375
"""
372
376
377
+
378
+
379
+
373
380
if self .WantPrefixLen == None and wantprefixlen == None :
374
381
wantprefixlen = 1
375
382
@@ -1022,10 +1029,10 @@ def v46map(self):
1022
1029
raise ValueError ("%s cannot be converted to an IPv4 address."
1023
1030
% repr (self ))
1024
1031
1025
- class IPSet (collections .MutableSet ):
1032
+ class IPSet (collections_abc .MutableSet ):
1026
1033
def __init__ (self , iterable = []):
1027
1034
# Make sure it's iterable, otherwise wrap
1028
- if not isinstance (iterable , collections .Iterable ):
1035
+ if not isinstance (iterable , collections_abc .Iterable ):
1029
1036
raise TypeError ("'%s' object is not iterable" % type (iterable ).__name__ )
1030
1037
1031
1038
# Make sure we only accept IP objects
@@ -1099,7 +1106,7 @@ def len(self):
1099
1106
1100
1107
def add (self , value ):
1101
1108
# Make sure it's iterable, otherwise wrap
1102
- if not isinstance (value , collections .Iterable ):
1109
+ if not isinstance (value , collections_abc .Iterable ):
1103
1110
value = [value ]
1104
1111
1105
1112
# Check type
@@ -1113,7 +1120,7 @@ def add(self, value):
1113
1120
1114
1121
def discard (self , value ):
1115
1122
# Make sure it's iterable, otherwise wrap
1116
- if not isinstance (value , collections .Iterable ):
1123
+ if not isinstance (value , collections_abc .Iterable ):
1117
1124
value = [value ]
1118
1125
1119
1126
# This is much faster than iterating over the addresses
0 commit comments