Irit Katriel <[email protected]> added the comment:
1. For a comment line, the tokenizer emits a COMMENT token followed by an NL
token for the newline. The inspect.BlockFinder.tokeneater increments its "last"
field to the last line it identified as belonging to the code block. Currently
it increments it when it sees a NEWLINE token, but not for an NL token.
2. For a comment line, the tokenizer does not emit an INDENT/DEDENT token, so
the indentation level when it is processes is assumed to be equal to that of
the previous line.
PR 23630 aims to include comment lines in the block if their start column is
after the start column of the opening line of the block:
def f():
return 42
# this is a part of f
# this is not a part of f
----------
nosy: +taleinat
versions: +Python 3.10, Python 3.9
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue42116>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com