Original file line numberDiff line numberDiff line change@@ -604,7 +604,7 @@ def _tokenize(readline, encoding):
604604pos+=1
605605606606# Add an implicit NEWLINE if the input doesn't end in one
607-iflast_lineandlast_line[-1] notin'\r\n':
607+iflast_lineandlast_line[-1] notin'\r\n'andnotlast_line.strip().startswith("#"):
608608yieldTokenInfo(NEWLINE, '', (lnum-1, len(last_line)), (lnum-1, len(last_line) +1), '')
609609forindentinindents[1:]: # pop remaining indent levels
610610yieldTokenInfo(DEDENT, '', (lnum, 0), (lnum, 0), '')