Skip to content

Commit

Permalink
🐎 FileWrapper.peek returns None when out of elements
Browse files Browse the repository at this point in the history
  • Loading branch information
miyuchina committed Jan 9, 2018
1 parent 49c9b87 commit c458c79
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions mistletoe/block_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,10 @@ def start(cls, line):
@classmethod
def read(cls, lines):
line_buffer = []
try:
while cls._is_legal(lines.peek()) and lines.peek() != '\n':
line_buffer.append(next(lines))
except StopIteration:
pass
while (lines.peek() is not None
and cls._is_legal(lines.peek())
and lines.peek() != '\n'):
line_buffer.append(next(lines))
return line_buffer


Expand Down
2 changes: 1 addition & 1 deletion mistletoe/block_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def reset(self):
def peek(self):
if self._index + 1 < len(self.lines):
return self.lines[self._index+1]
raise StopIteration
return None


def tokenize(iterable, token_types, root=None):
Expand Down

0 comments on commit c458c79

Please sign in to comment.