File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -688,15 +688,16 @@ def lex_space(self) -> None:
688
688
def lex_indent (self ) -> None :
689
689
"""Analyze whitespace chars at the beginning of a line (indents)."""
690
690
s = self .match (self .indent_exp )
691
- if s != '' and s [- 1 ] in self .comment_or_newline :
691
+ while True :
692
+ s = self .match (self .indent_exp )
693
+ if s == '' or s [- 1 ] not in self .comment_or_newline :
694
+ break
692
695
# Empty line (whitespace only or comment only).
693
696
self .add_pre_whitespace (s [:- 1 ])
694
697
if s [- 1 ] == '#' :
695
698
self .lex_comment ()
696
699
else :
697
700
self .lex_break ()
698
- self .lex_indent ()
699
- return
700
701
indent = self .calc_indent (s )
701
702
if indent == self .indents [- 1 ]:
702
703
# No change in indent: just whitespace.
Original file line number Diff line number Diff line change @@ -426,6 +426,10 @@ def test_byte_order_mark(self):
426
426
self .assert_lex ('\ufeff "\xbb "' .encode ('utf8' ),
427
427
'Bom(\ufeff ) StrLit("\xbb ") Break() Eof()' )
428
428
429
+ def test_long_comment (self ):
430
+ prog = '# pass\n ' * 1000
431
+ self .assert_lex (prog , 'Eof(%s)' % repr (prog )[1 :- 1 ])
432
+
429
433
# TODO
430
434
# invalid escape sequences in string literals etc.
431
435
You can’t perform that action at this time.
0 commit comments