diff --git a/utils/lit/lit/ShUtil.py b/utils/lit/lit/ShUtil.py index 8a292f46cc8..a7892a43ab4 100644 --- a/utils/lit/lit/ShUtil.py +++ b/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/utils/lit/lit/main.py b/utils/lit/lit/main.py index 31001595b3f..84ed016f0c3 100755 --- a/utils/lit/lit/main.py +++ b/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