Skip to content

Conversation

@pablogsal
Copy link
Member

@pablogsalpablogsal commented May 26, 2023

@lysnikolaou
Copy link
Member

@pablogsal Can you provide a very quick explanation of how this works and changes the location of the DEDENT token? Nothing too detailed, just a quick overview of the though process, cause I'm having difficulties understanding this.

@pablogsal
Copy link
MemberAuthor

Can you provide a very quick explanation of how this works and changes the location of the DEDENT token?

Yep: the objective is that inplicit dedents like these:

if X: if Y: ... 

are reported in the same line as the ENDMARKER. For doing this we note that trailing dedent tokens are emitted in a situation where the tokenizer has reached EOF so tok->done is E_EOF for all of them, which is great because this allows to identify them easily. We add now a branch for these to put the line number that is expected as the previous tokenizer.

Unfortunately, this forces us to handle ENDMARKER in the extension because otherwise we don't have enough information to get correctly the line for it because checking the last token may now have these "artificial" new lines.

@pablogsal
Copy link
MemberAuthor

Tell me if something else is not clear:)

@pablogsal
Copy link
MemberAuthor

@pablogsal Can you provide a very quick explanation of how this works and changes the location of the DEDENT token? Nothing too detailed, just a quick overview of the though process, cause I'm having difficulties understanding this.

Ah wait, I forgot to push some commits 😓

@lysnikolaou
Copy link
Member

lysnikolaou commented May 26, 2023

Ah wait, I forgot to push some commits 😓

Aha! Ok, makes sense now. Thanks for the explanation though, man!

@pablogsalpablogsalforce-pushed the gh-104976 branch 2 times, most recently from 8a23a18 to 19a58c5CompareMay 26, 2023 15:21
@pablogsal
Copy link
MemberAuthor

Aha! Ok, makes sense now. Thanks for the explanation though, man!

Sorry for the confusion! 😅 Check again when you have time!

Copy link
Member

@lysnikolaoulysnikolaou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup! Looks good!

…vious tokenizer Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
@pablogsalpablogsal added the needs backport to 3.12 only security fixes label May 26, 2023
@pablogsalpablogsal merged commit 46b52e6 into python:mainMay 26, 2023
@pablogsalpablogsal deleted the gh-104976 branch May 26, 2023 21:02
@miss-islington
Copy link
Contributor

Thanks @pablogsal for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-105000 is a backport of this pull request to the 3.12 branch.

@bedevere-botbedevere-bot removed the needs backport to 3.12 only security fixes label May 26, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 26, 2023
…vious tokenizer (pythonGH-104980) (cherry picked from commit 46b52e6) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com> Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
pablogsal pushed a commit that referenced this pull request May 26, 2023
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@pablogsal@lysnikolaou@miss-islington@bedevere-bot