You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On 3.12, the last two lines (a, )) are not returned as part of the source lines. When I tried to minify by removing the first assert_is_value() call, it instead returned the print() line as part of the function.
This is a bug in the implementation of the new tokenize module. The tokenizer checks whether something is in a parenthesized block in order to emit a NL token instead of a NEWLINE token. It also sets and unsets a flag about a comment-only line, in order to do the same. When both are true (a comment inside a parenthesized block), it nevers resets the comment flag. Here's a minimal example:
cpythonon main [$?] viaCv14.0.3-clangvia 🐍 pyenv3.11.3
❯ cathello.py
[
# hello1
]
cpythonon main [$?] viaCv14.0.3-clangvia 🐍 pyenv3.11.3
❯ ./python.exe-mtokenizehello.py0,0-0,0: ENCODING'utf-8'1,0-1,1: OP'['1,1-1,2: NL'\n'2,4-2,11: COMMENT'# hello'2,11-2,12: NL'\n'3,4-3,5: NUMBER'1'3,5-3,6: NL'\n'4,0-4,1: OP']'4,1-4,2: NL'\n'# This should be a NEWLINE instead 5,0-5,0: ENDMARKER''
Activity
lysnikolaou commentedon May 24, 2023
This is a bug in the implementation of the new tokenize module. The tokenizer checks whether something is in a parenthesized block in order to emit a
NLtoken instead of aNEWLINEtoken. It also sets and unsets a flag about a comment-only line, in order to do the same. When both are true (a comment inside a parenthesized block), it nevers resets the comment flag. Here's a minimal example:I'm opening a PR shortly.
pythongh-104866: Tokenize should emit NEWLINE after exiting block wit…
gh-104866: Tokenize should emit NEWLINE after exiting block with comm…
pythongh-104866: Tokenize should emit NEWLINE after exiting block wit…
[3.12] gh-104866: Tokenize should emit NEWLINE after exiting block wi…