From 3a90aebd3a5cebb9bb59edd7c14630b6b95f6e47 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Wed, 7 Aug 2013 03:20:54 +0000 Subject: [PATCH] [lit] Avoid use of iterator .next() method. llvm-svn: 187858 --- llvm/utils/lit/lit/ShUtil.py | 15 +++++++-------- llvm/utils/lit/lit/main.py | 7 +++---- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/llvm/utils/lit/lit/ShUtil.py b/llvm/utils/lit/lit/ShUtil.py index 8a292f46cc82..a7892a43ab43 100644 --- a/llvm/utils/lit/lit/ShUtil.py +++ b/llvm/utils/lit/lit/ShUtil.py @@ -174,16 +174,15 @@ class ShParser: self.tokens = ShLexer(data, win32Escapes = win32Escapes).lex() def lex(self): - try: - return self.tokens.next() - except StopIteration: - return None + for item in self.tokens: + return item + return None def look(self): - next = self.lex() - if next is not None: - self.tokens = itertools.chain([next], self.tokens) - return next + token = self.lex() + if token is not None: + self.tokens = itertools.chain([token], self.tokens) + return token def parse_command(self): tok = self.lex() diff --git a/llvm/utils/lit/lit/main.py b/llvm/utils/lit/lit/main.py index 31001595b3f2..84ed016f0c39 100755 --- a/llvm/utils/lit/lit/main.py +++ b/llvm/utils/lit/lit/main.py @@ -94,10 +94,9 @@ class TestProvider: if self.canceled: self.lock.release() return None - - try: - item = self.iter.next() - except StopIteration: + for item in self.iter: + break + else: item = None self.lock.release() return item