From b83e916ec888b38b15a242c673c89da39b52a8e7 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Thu, 25 Mar 2021 19:28:07 -0600 Subject: handle iterator end more gracefully in peek --- yapymake/makefile/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'yapymake/makefile/__init__.py') diff --git a/yapymake/makefile/__init__.py b/yapymake/makefile/__init__.py index ddd049d..a5cb19d 100644 --- a/yapymake/makefile/__init__.py +++ b/yapymake/makefile/__init__.py @@ -130,8 +130,9 @@ class Makefile: prerequisite_tokens, command_tokens = semicolon_split prerequisites = self.expand_macros(prerequisite_tokens).split() command_token_strings = [command_tokens] - while lines_iter.peek().startswith('\t'): - command_token_strings.append(tokenize(next(lines_iter).lstrip('\t'))) + while (peeked := lines_iter.peek()) is not None and peeked.startswith('\t'): + # TODO handle escaped newlines + command_token_strings.append(tokenize(next(lines_iter).lstrip('\t').rstrip('\n'))) commands = [CommandLine(c) for c in command_token_strings] # we don't know yet if it's a target rule or an inference rule -- cgit v1.2.3