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
{{ message }}
Repository navigation
Token lines in the tokenize module always end in new line #104825
As a consequence of the changes in the Python tokenizer post PEP701, now the line attribute always ends in a new line character. We should remove this as it adds no information and wasn't there before.
@pablogsal Do you think the above should be fixed? Will you work on it?
Hummmmm, not sure how easy is going to be for us to distinguish between implicit and explicit newlines at the end. I would say, leave it like is now unless you disagree, in which case let's see if we can fix it easily.
As a consequence of the changes in the Python tokenizer post PEP701, now the line attribute always ends in a new line character. We should remove this as it adds no information and wasn't there before.
But it looks to me like the lines used to always end in newline, except for ENDMARKER. This uses tokbug.py from #104972:
Activity
lysnikolaou commentedon May 24, 2023
Yeah, I ran across that while working on #104798. Are you already working on a fix or shall I take it up?
pablogsal commentedon May 24, 2023
I am working on a fix, should be up in half an hour or so
pythongh-104825: Remove implicit newline in the line attribute in tok…
gh-104825: Remove implicit newline in the line attribute in tokens em…
[3.12] pythongh-104825: Remove implicit newline in the line attribute…
lysnikolaou commentedon May 24, 2023
#104846 now removes a newline, even when a newline exists in the original source.
[3.12] gh-104825: Remove implicit newline in the line attribute in to…
lysnikolaou commentedon May 24, 2023
@pablogsal Do you think the above should be fixed? Will you work on it?
pablogsal commentedon May 24, 2023
Hummmmm, not sure how easy is going to be for us to distinguish between implicit and explicit newlines at the end. I would say, leave it like is now unless you disagree, in which case let's see if we can fix it easily.
lysnikolaou commentedon May 24, 2023
My only concern is that tests that rely on that will fail. For example,
test_pegennow fails:The failure is:
The fix is very simple, so I'm okay with going with this as-is. I will fix
test_pegenin my setuptools PR.[3.12] pythongh-104825: add omitted idlelib text fix
[3.12] gh-104825: add omitted idlelib text fix (#104880)
nedbat commentedon May 26, 2023
You say:
But it looks to me like the lines used to always end in newline, except for ENDMARKER. This uses tokbug.py from #104972: