diff options
author | Kaleb S. KEITHLEY <kkeithle@redhat.com> | 2018-05-02 08:48:32 -0400 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2018-05-30 03:37:46 +0000 |
commit | 202d27c5309f2b5a2c4cda4af2e9a1ec85e1e9ad (patch) | |
tree | 80434465328987f4bde5a57e16bbff76ccf9f555 /contrib | |
parent | 7e72af7657973d508c179922bd29257ff8402bcd (diff) |
core/various: python3 compat, prepare for python2 -> python3
see https://review.gluster.org/#/c/19788/ and
https://review.gluster.org/#/c/19871/
Selected small fixes from 2to3 utility. Specifically apply, basestring,
funcattrs, idioms, numliterals, set_literal, types, urllib, zip
Note: these 2to3 fixes report no changes are necessary: exec, execfile,
exitfunc, filter, getcwdu, intern, itertools, metaclass, methodattrs, ne,
next, nonzero, operator, paren, raw_input, reduce, reload, renames, repr,
standarderror, sys_exc, throw, tuple_params, xreadlines.
Any 2to3 fixes not in the above two lists have more extensive changes
which will follow in separate patches.
most unicode changes suggested by 2to3 will need to be applied at the
same time as changing the shebangs from python2 to python3. Prashanth
notes that unicode strings in py2 need 'u' prefix; unicode strings in
py3 3.0, 3.1, and 3.2 a 'u' prefix will throw an error, but in py3 3.3+
it is legal (or just ignored). All Linux dists we care about have 3.3
or later so we can leave 'u' prefixes on unicode strings.
Change-Id: I49bba2f328b0ee24b9a8115a7183be979981563e
updates: #411
Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/ipaddr-py/ipaddr.py | 4 | ||||
-rwxr-xr-x | contrib/ipaddr-py/ipaddr_test.py | 7 |
2 files changed, 5 insertions, 6 deletions
diff --git a/contrib/ipaddr-py/ipaddr.py b/contrib/ipaddr-py/ipaddr.py index 07fc873fb15..6ebd22a33ce 100644 --- a/contrib/ipaddr-py/ipaddr.py +++ b/contrib/ipaddr-py/ipaddr.py @@ -1222,7 +1222,7 @@ class IPv4Network(_BaseV4, _BaseNet): """ # the valid octets for host and netmasks. only useful for IPv4. - _valid_mask_octets = set((255, 254, 252, 248, 240, 224, 192, 128, 0)) + _valid_mask_octets = {255, 254, 252, 248, 240, 224, 192, 128, 0} def __init__(self, address, strict=False): """Instantiate a new IPv4 network object. @@ -1465,7 +1465,7 @@ class _BaseV6(object): try: # Now, parse the hextets into a 128-bit integer. - ip_int = 0L + ip_int = 0 for i in xrange(parts_hi): ip_int <<= 16 ip_int |= self._parse_hextet(parts[i]) diff --git a/contrib/ipaddr-py/ipaddr_test.py b/contrib/ipaddr-py/ipaddr_test.py index 642466fa2ce..c56ecb5c4b1 100755 --- a/contrib/ipaddr-py/ipaddr_test.py +++ b/contrib/ipaddr-py/ipaddr_test.py @@ -265,7 +265,7 @@ class IpaddrUnitTest(unittest.TestCase): '2001:658:22a:cafe:200::1') def testGetNetmask(self): - self.assertEqual(int(self.ipv4.netmask), 4294967040L) + self.assertEqual(int(self.ipv4.netmask), 4294967040) self.assertEqual(str(self.ipv4.netmask), '255.255.255.0') self.assertEqual(str(self.ipv4_hostmask.netmask), '255.0.0.0') self.assertEqual(int(self.ipv6.netmask), @@ -282,7 +282,7 @@ class IpaddrUnitTest(unittest.TestCase): self.assertTrue(ipv6_zero_netmask._is_valid_netmask(str(0))) def testGetBroadcast(self): - self.assertEqual(int(self.ipv4.broadcast), 16909311L) + self.assertEqual(int(self.ipv4.broadcast), 16909311) self.assertEqual(str(self.ipv4.broadcast), '1.2.3.255') self.assertEqual(int(self.ipv6.broadcast), @@ -681,8 +681,7 @@ class IpaddrUnitTest(unittest.TestCase): ip3 = ipaddr.IPNetwork('10.10.10.2/31') ip4 = ipaddr.IPNetwork('10.10.10.2') sorted = [ip1, ip2, ip3, ip4] - unsorted = [ip2, ip4, ip1, ip3] - unsorted.sort() + unsorted = sorted([ip2, ip4, ip1, ip3]) self.assertEqual(sorted, unsorted) unsorted = [ip4, ip1, ip3, ip2] unsorted.sort() |