Py3 compatibility fixes

This commit is contained in:
Pedro Algarvio 2014-11-22 10:38:15 +00:00
parent 88ddd58bbb
commit aa5eaea4e3

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
#!/usr/bin/python #!/usr/bin/python
# -*- coding: utf-8 -*-
# #
# Copyright 2007 Google Inc. # Copyright 2007 Google Inc.
# Licensed to PSF under a Contributor Agreement. # Licensed to PSF under a Contributor Agreement.
@ -28,8 +28,9 @@ and networks.
from __future__ import absolute_import from __future__ import absolute_import
import struct import struct
# Import salt libs # Import 3rd-party libs
from salt.ext.six.moves import range import salt.ext.six as six
from salt.ext.six.moves import range # pylint: disable=import-error,redefined-builtin
__version__ = 'trunk' __version__ = 'trunk'
@ -1204,7 +1205,7 @@ class IPv4Address(_BaseV4, _BaseIP):
_BaseV4.__init__(self, address) _BaseV4.__init__(self, address)
# Efficient constructor from integer. # Efficient constructor from integer.
if isinstance(address, (int, long)): if isinstance(address, six.integer_types):
self._ip = address self._ip = address
if address < 0 or address > self._ALL_ONES: if address < 0 or address > self._ALL_ONES:
raise AddressValueError(address) raise AddressValueError(address)
@ -1286,7 +1287,7 @@ class IPv4Network(_BaseV4, _BaseNet):
_BaseV4.__init__(self, address) _BaseV4.__init__(self, address)
# Constructing from an integer or packed bytes. # Constructing from an integer or packed bytes.
if isinstance(address, (int, long, Bytes)): if isinstance(address, tuple(list(six.integer_types) + [Bytes])):
self.ip = IPv4Address(address) self.ip = IPv4Address(address)
self._ip = self.ip._ip self._ip = self.ip._ip
self._prefixlen = self._max_prefixlen self._prefixlen = self._max_prefixlen
@ -1780,7 +1781,7 @@ class IPv6Address(_BaseV6, _BaseIP):
_BaseV6.__init__(self, address) _BaseV6.__init__(self, address)
# Efficient constructor from integer. # Efficient constructor from integer.
if isinstance(address, (int, long)): if isinstance(address, six.integer_types):
self._ip = address self._ip = address
if address < 0 or address > self._ALL_ONES: if address < 0 or address > self._ALL_ONES:
raise AddressValueError(address) raise AddressValueError(address)
@ -1854,7 +1855,7 @@ class IPv6Network(_BaseV6, _BaseNet):
_BaseV6.__init__(self, address) _BaseV6.__init__(self, address)
# Constructing from an integer or packed bytes. # Constructing from an integer or packed bytes.
if isinstance(address, (int, long, Bytes)): if isinstance(address, tuple(list(six.integer_types) + [Bytes])):
self.ip = IPv6Address(address) self.ip = IPv6Address(address)
self._ip = self.ip._ip self._ip = self.ip._ip
self._prefixlen = self._max_prefixlen self._prefixlen = self._max_prefixlen