From 9c23644e7bfd259bc63589564ef9303b279d727a Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Mon, 3 Oct 2016 18:42:15 -0500 Subject: [PATCH] Fix error condition in LexIterator.is_next --- pytools/lex.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pytools/lex.py b/pytools/lex.py index a1c4914..3322d0c 100644 --- a/pytools/lex.py +++ b/pytools/lex.py @@ -136,7 +136,9 @@ class LexIterator(object): return self.index + i >= len(self.lexed) def is_next(self, tag, i=0): - return self.next_tag(i) is tag + return ( + self.index + i < len(self.lexed) + and self.next_tag(i) is tag) def raise_parse_error(self, msg): if self.is_at_end(): -- GitLab