[U-Boot] [PATCH v2 2/8] test/py: Use range() rather than xrange()
Paul Burton
paul.burton at imgtec.com
Thu Sep 14 21:34:44 UTC 2017
In python 3.x the xrange() function has been removed, and range()
returns an iterator much like Python 2.x's xrange(). Simply use range()
in place of xrange() in order to work on both python 2.x & 3.x. This
will mean a small cost on python 2.x since range() will return a list
there rather than an iterator, but the cost should be negligible.
Signed-off-by: Paul Burton <paul.burton at imgtec.com>
Reviewed-by: Stephen Warren <swarren at nvidia.com>
---
Changes in v2: None
test/py/u_boot_console_sandbox.py | 2 +-
test/py/u_boot_spawn.py | 6 +++---
test/py/u_boot_utils.py | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/test/py/u_boot_console_sandbox.py b/test/py/u_boot_console_sandbox.py
index 9a2fe9cb59..5c91d926c5 100644
--- a/test/py/u_boot_console_sandbox.py
+++ b/test/py/u_boot_console_sandbox.py
@@ -82,7 +82,7 @@ class ConsoleSandbox(ConsoleBase):
p = self.p
self.p = None
- for i in xrange(100):
+ for i in range(100):
ret = not p.isalive()
if ret:
break
diff --git a/test/py/u_boot_spawn.py b/test/py/u_boot_spawn.py
index 15ca4ac838..638c5dd31d 100644
--- a/test/py/u_boot_spawn.py
+++ b/test/py/u_boot_spawn.py
@@ -135,7 +135,7 @@ class Spawn(object):
the expected time.
"""
- for pi in xrange(len(patterns)):
+ for pi in range(len(patterns)):
if type(patterns[pi]) == type(''):
patterns[pi] = re.compile(patterns[pi])
@@ -144,7 +144,7 @@ class Spawn(object):
while True:
earliest_m = None
earliest_pi = None
- for pi in xrange(len(patterns)):
+ for pi in range(len(patterns)):
pattern = patterns[pi]
m = pattern.search(self.buf)
if not m:
@@ -199,7 +199,7 @@ class Spawn(object):
"""
os.close(self.fd)
- for i in xrange(100):
+ for i in range(100):
if not self.isalive():
break
time.sleep(0.1)
diff --git a/test/py/u_boot_utils.py b/test/py/u_boot_utils.py
index 2ba4baed07..264508da4e 100644
--- a/test/py/u_boot_utils.py
+++ b/test/py/u_boot_utils.py
@@ -120,7 +120,7 @@ def wait_until_open_succeeds(fn):
An open file handle to the file.
"""
- for i in xrange(100):
+ for i in range(100):
fh = attempt_to_open_file(fn)
if fh:
return fh
@@ -143,7 +143,7 @@ def wait_until_file_open_fails(fn, ignore_errors):
Nothing.
"""
- for i in xrange(100):
+ for i in range(100):
fh = attempt_to_open_file(fn)
if not fh:
return
--
2.14.1
More information about the U-Boot
mailing list