[llvm] r187858 - [lit] Avoid use of iterator .next() method.

Daniel Dunbar daniel at zuster.org
Tue Aug 6 20:20:54 PDT 2013


Author: ddunbar
Date: Tue Aug  6 22:20:54 2013
New Revision: 187858

URL: http://llvm.org/viewvc/llvm-project?rev=187858&view=rev
Log:
[lit] Avoid use of iterator .next() method.

Modified:
    llvm/trunk/utils/lit/lit/ShUtil.py
    llvm/trunk/utils/lit/lit/main.py

Modified: llvm/trunk/utils/lit/lit/ShUtil.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/ShUtil.py?rev=187858&r1=187857&r2=187858&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/ShUtil.py (original)
+++ llvm/trunk/utils/lit/lit/ShUtil.py Tue Aug  6 22:20:54 2013
@@ -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()

Modified: llvm/trunk/utils/lit/lit/main.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/main.py?rev=187858&r1=187857&r2=187858&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/main.py (original)
+++ llvm/trunk/utils/lit/lit/main.py Tue Aug  6 22:20:54 2013
@@ -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





More information about the llvm-commits mailing list