From dffd56d1d270e4797e43272a6c9000b8b8aeaf29 Mon Sep 17 00:00:00 2001 From: Paul Burton Date: Thu, 14 Sep 2017 14:34:43 -0700 Subject: test/py: Make print statements python 3.x safe In python 3.x print must be called as a function rather than used as a statement. Update uses of print to the function call syntax in order to be python 3.x safe. Signed-off-by: Paul Burton Reviewed-by: Stephen Warren --- test/py/u_boot_spawn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/py/u_boot_spawn.py') diff --git a/test/py/u_boot_spawn.py b/test/py/u_boot_spawn.py index 108498a9a4b..77a010a33f0 100644 --- a/test/py/u_boot_spawn.py +++ b/test/py/u_boot_spawn.py @@ -58,7 +58,7 @@ class Spawn(object): os.chdir(cwd) os.execvp(args[0], args) except: - print 'CHILD EXECEPTION:' + print('CHILD EXECEPTION:') import traceback traceback.print_exc() finally: -- cgit v1.2.3 From b8c455500a08c75c4809e523d348027e72cda7ec Mon Sep 17 00:00:00 2001 From: Paul Burton Date: Thu, 14 Sep 2017 14:34:44 -0700 Subject: test/py: Use range() rather than xrange() 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 Reviewed-by: Stephen Warren --- test/py/u_boot_spawn.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test/py/u_boot_spawn.py') diff --git a/test/py/u_boot_spawn.py b/test/py/u_boot_spawn.py index 77a010a33f0..b011a3e3da2 100644 --- a/test/py/u_boot_spawn.py +++ b/test/py/u_boot_spawn.py @@ -134,7 +134,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]) @@ -143,7 +143,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: @@ -198,7 +198,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) -- cgit v1.2.3