9
9
__version__ = '1.00'
10
10
11
11
import bisect
12
- import collections
13
12
import sys
14
13
import types
14
+ try :
15
+ import collections .abc as collections_abc
16
+ except ImportError :
17
+ import collections as collections_abc
15
18
16
19
# Definition of the Ranges for IPv4 IPs
17
20
# this should include www.iana.org/assignments/ipv4-address-space
@@ -1022,10 +1025,10 @@ def v46map(self):
1022
1025
raise ValueError ("%s cannot be converted to an IPv4 address."
1023
1026
% repr (self ))
1024
1027
1025
- class IPSet (collections .MutableSet ):
1028
+ class IPSet (collections_abc .MutableSet ):
1026
1029
def __init__ (self , iterable = []):
1027
1030
# Make sure it's iterable, otherwise wrap
1028
- if not isinstance (iterable , collections .Iterable ):
1031
+ if not isinstance (iterable , collections_abc .Iterable ):
1029
1032
raise TypeError ("'%s' object is not iterable" % type (iterable ).__name__ )
1030
1033
1031
1034
# Make sure we only accept IP objects
@@ -1099,7 +1102,7 @@ def len(self):
1099
1102
1100
1103
def add (self , value ):
1101
1104
# Make sure it's iterable, otherwise wrap
1102
- if not isinstance (value , collections .Iterable ):
1105
+ if not isinstance (value , collections_abc .Iterable ):
1103
1106
value = [value ]
1104
1107
1105
1108
# Check type
@@ -1113,7 +1116,7 @@ def add(self, value):
1113
1116
1114
1117
def discard (self , value ):
1115
1118
# Make sure it's iterable, otherwise wrap
1116
- if not isinstance (value , collections .Iterable ):
1119
+ if not isinstance (value , collections_abc .Iterable ):
1117
1120
value = [value ]
1118
1121
1119
1122
# This is much faster than iterating over the addresses
0 commit comments