Python 2 had range() and xrange().  xrange() is more efficient, but
behaves differently so range() was retained for compatibility.  Python 3
only has range() and it behaves like Python 2's xrange().

Remove explicit use of xrange() and use six.moves.range() to
make sure we're using xrange() from Python 2 or range() from Python 3.

Signed-off-by: Russell Bryant <russ...@ovn.org>
---
 debian/ovs-monitor-ipsec     | 1 +
 python/ovs/json.py           | 2 ++
 python/ovs/ovsuuid.py        | 2 ++
 python/ovs/socket_util.py    | 4 +++-
 python/ovs/unixctl/server.py | 2 ++
 python/ovs/vlog.py           | 2 ++
 python/ovstest/util.py       | 1 +
 tests/test-vlog.py           | 3 ++-
 vtep/ovs-vtep                | 1 +
 9 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/debian/ovs-monitor-ipsec b/debian/ovs-monitor-ipsec
index efab91b..22883fc 100755
--- a/debian/ovs-monitor-ipsec
+++ b/debian/ovs-monitor-ipsec
@@ -39,6 +39,7 @@ import ovs.db.idl
 import ovs.unixctl
 import ovs.unixctl.server
 import ovs.vlog
+from six.moves import range
 
 vlog = ovs.vlog.Vlog("ovs-monitor-ipsec")
 root_prefix = ''                # Prefix for absolute file names, for testing.
diff --git a/python/ovs/json.py b/python/ovs/json.py
index 4e87726..07fd9c1 100644
--- a/python/ovs/json.py
+++ b/python/ovs/json.py
@@ -16,6 +16,8 @@ import re
 import StringIO
 import sys
 
+from six.moves import range
+
 __pychecker__ = 'no-stringiter'
 
 escapes = {ord('"'): u"\\\"",
diff --git a/python/ovs/ovsuuid.py b/python/ovs/ovsuuid.py
index 5cc0e1d..f2d48ea 100644
--- a/python/ovs/ovsuuid.py
+++ b/python/ovs/ovsuuid.py
@@ -15,6 +15,8 @@
 import re
 import uuid
 
+from six.moves import range
+
 from ovs.db import error
 import ovs.db.parser
 
diff --git a/python/ovs/socket_util.py b/python/ovs/socket_util.py
index 586c23a..57b1992 100644
--- a/python/ovs/socket_util.py
+++ b/python/ovs/socket_util.py
@@ -19,6 +19,8 @@ import random
 import socket
 import sys
 
+from six.moves import range
+
 import ovs.fatal_signal
 import ovs.poller
 import ovs.vlog
@@ -32,7 +34,7 @@ def make_short_name(long_name):
     long_name = os.path.abspath(long_name)
     long_dirname = os.path.dirname(long_name)
     tmpdir = os.getenv('TMPDIR', '/tmp')
-    for x in xrange(0, 1000):
+    for x in range(0, 1000):
         link_name = \
             '%s/ovs-un-py-%d-%d' % (tmpdir, random.randint(0, 10000), x)
         try:
diff --git a/python/ovs/unixctl/server.py b/python/ovs/unixctl/server.py
index c750fe9..9744cf2 100644
--- a/python/ovs/unixctl/server.py
+++ b/python/ovs/unixctl/server.py
@@ -17,6 +17,8 @@ import errno
 import os
 import types
 
+from six.moves import range
+
 import ovs.dirs
 import ovs.jsonrpc
 import ovs.stream
diff --git a/python/ovs/vlog.py b/python/ovs/vlog.py
index 0065020..6dcccbb 100644
--- a/python/ovs/vlog.py
+++ b/python/ovs/vlog.py
@@ -22,6 +22,8 @@ import socket
 import sys
 import threading
 
+from six.moves import range
+
 import ovs.dirs
 import ovs.unixctl
 import ovs.util
diff --git a/python/ovstest/util.py b/python/ovstest/util.py
index a522195..830feba 100644
--- a/python/ovstest/util.py
+++ b/python/ovstest/util.py
@@ -26,6 +26,7 @@ import signal
 import subprocess
 import re
 
+from six.moves import range
 import six.moves.xmlrpc_client
 
 
diff --git a/tests/test-vlog.py b/tests/test-vlog.py
index f6d0cec..ecfa26f 100644
--- a/tests/test-vlog.py
+++ b/tests/test-vlog.py
@@ -15,10 +15,11 @@
 import argparse
 
 import ovs.vlog
+from six.moves import range
 
 
 def main():
-    modules = [ovs.vlog.Vlog("module_%d" % i) for i in xrange(3)]
+    modules = [ovs.vlog.Vlog("module_%d" % i) for i in range(3)]
 
     parser = argparse.ArgumentParser(description="Vlog Module Tester")
     ovs.vlog.add_args(parser)
diff --git a/vtep/ovs-vtep b/vtep/ovs-vtep
index dd5b1a7..1db4e05 100755
--- a/vtep/ovs-vtep
+++ b/vtep/ovs-vtep
@@ -29,6 +29,7 @@ import ovs.util
 import ovs.daemon
 import ovs.unixctl.server
 import ovs.vlog
+from six.moves import range
 
 
 VERSION = "0.99"
-- 
2.5.0

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to