summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorKaleb S. KEITHLEY <kkeithle@redhat.com>2018-06-05 09:49:23 -0400
committerAmar Tumballi <amarts@redhat.com>2018-06-07 09:34:31 +0000
commitd788cc59b1cd4278ca0b8b2d9f6fe93f80550af3 (patch)
treebc467e1adf6b5e7e7292b4790b1e94f194b99368 /contrib
parentfe71ee74fd327f61aedc858699a953a0fe2cd8d4 (diff)
core/various: python3 compat, prepare for python2 -> python3
see https://review.gluster.org/#/c/19788/, https://review.gluster.org/#/c/19871/, https://review.gluster.org/#/c/19952/, and https://review.gluster.org/#/c/20104/ This patch changes uses of xrange() to range(), as suggested by the python 2to3 utility. https://www.geeksforgeeks.org/range-vs-xrange-python/ In Python 3, there is no xrange , but the range function behaves like xrange in Python 2. (My concern is that range() in python2 may behave differently until we "throw the switch" to switch to python3.) Note: Fedora packaging guidelines require explicit shebangs, so popular practices like #!/usr/bin/env python and #!/usr/bin/python are not allowed; they must be #!/usr/bin/python2 or #!/usr/bin/python3 Note: Selected small fixes from 2to3 utility. Specifically apply, basestring, funcattrs, idioms, numliterals, set_literal, types, urllib, and zip have already been applied. Also version agnostic imports for urllib, cpickle, socketserver, _thread, queue, etc., suggested by Aravinda in https://review.gluster.org/#/c/19767/1 Note: these 2to3 fixes report no changes are necessary: asserts, buffer, 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. Change-Id: I16ae9f4e3a4fd02a0623fb6f9fdb7aaf65f2a8a9 updates: #411 Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
Diffstat (limited to 'contrib')
-rw-r--r--contrib/ipaddr-py/ipaddr.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/contrib/ipaddr-py/ipaddr.py b/contrib/ipaddr-py/ipaddr.py
index 6ebd22a33ce..61033e238d1 100644
--- a/contrib/ipaddr-py/ipaddr.py
+++ b/contrib/ipaddr-py/ipaddr.py
@@ -1079,7 +1079,7 @@ class _BaseV4(object):
"""
octets = []
- for _ in xrange(4):
+ for _ in range(4):
octets.insert(0, str(ip_int & 0xFF))
ip_int >>= 8
return '.'.join(octets)
@@ -1431,7 +1431,7 @@ class _BaseV6(object):
# This indicates that a run of zeroes has been skipped.
try:
skip_index, = (
- [i for i in xrange(1, len(parts) - 1) if not parts[i]] or
+ [i for i in range(1, len(parts) - 1) if not parts[i]] or
[None])
except ValueError:
# Can't have more than one '::'
@@ -1466,11 +1466,11 @@ class _BaseV6(object):
try:
# Now, parse the hextets into a 128-bit integer.
ip_int = 0
- for i in xrange(parts_hi):
+ for i in range(parts_hi):
ip_int <<= 16
ip_int |= self._parse_hextet(parts[i])
ip_int <<= 16 * parts_skipped
- for i in xrange(-parts_lo, 0):
+ for i in range(-parts_lo, 0):
ip_int <<= 16
ip_int |= self._parse_hextet(parts[i])
return ip_int
@@ -1589,7 +1589,7 @@ class _BaseV6(object):
ip_int = self._ip_int_from_string(ip_str)
parts = []
- for i in xrange(self._HEXTET_COUNT):
+ for i in range(self._HEXTET_COUNT):
parts.append('%04x' % (ip_int & 0xFFFF))
ip_int >>= 16
parts.reverse()