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

llvm-svn: 187858
This commit is contained in:
Daniel Dunbar 2013-08-07 03:20:54 +00:00
parent a3ef2f2dd8
commit 3a90aebd3a
2 changed files with 10 additions and 12 deletions

View File

@ -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()

View File

@ -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