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 the one 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> --- 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 | 4 +++- 6 files changed, 14 insertions(+), 2 deletions(-) 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 8651c31..641ea47 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 3b9d835..830feba 100644 --- a/python/ovstest/util.py +++ b/python/ovstest/util.py @@ -23,10 +23,12 @@ import select import socket import struct import signal -import six.moves.xmlrpc_client import subprocess import re +from six.moves import range +import six.moves.xmlrpc_client + def str_ip(ip_address): """ -- 2.5.0 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev