GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-105069: Add a readline-like callable to the tokenizer to consume input iteratively by pablogsal · Pull Request #105070 · python/cpython

Conversation

@pablogsal

@pablogsal pablogsal commented May 29, 2023 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
  • Issue: Consider not consuming all the buffer in one go in the tokenizer module #105069

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@pablogsal
pablogsal force-pushed the tokenizer_iter branch from 9089ece to ff4d45c Compare May 29, 2023 19:14
@bedevere-bot bedevere-bot mentioned this pull request May 29, 2023
Consider not consuming all the buffer in one go in the tokenizer module #105069
Closed
@pablogsal
pablogsal force-pushed the tokenizer_iter branch from ff4d45c to bc6d2da Compare May 29, 2023 20:02
@pablogsal pablogsal mentioned this pull request May 29, 2023
W391: spurious warnings with python 3.12 beta PyCQA/pycodestyle#1142
Closed
@pablogsal
pablogsal force-pushed the tokenizer_iter branch 3 times, most recently from 0a661c4 to 713379f Compare May 29, 2023 20:29
@pablogsal
pablogsal marked this pull request as ready for review May 29, 2023 20:30
@pablogsal
pablogsal requested a review from lysnikolaou as a code owner May 29, 2023 20:30
@pablogsal
pablogsal force-pushed the tokenizer_iter branch from 713379f to 35328a4 Compare May 29, 2023 20:30
@pablogsal
pablogsal requested a review from lysnikolaou as a code owner May 29, 2023 20:30
@bedevere-bot bedevere-bot added the awaiting core review label May 29, 2023
pablogsal
pablogsal commented May 29, 2023
View reviewed changes
Comment thread Lib/test/test_tokenize.py
def get_tokens(string):
return list(_generate_tokens_from_c_tokenizer(string))

self.assertRaises(SyntaxError, get_tokens, "(1+2]")

@pablogsal pablogsal May 29, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This was bothering me 😅

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
pablogsal
pablogsal commented May 29, 2023
View reviewed changes
Comment thread Lib/tokenize.py
This has the same API as tokenize(), except that it expects the *readline*
callable to return str objects instead of bytes.
"""
def _gen():

@pablogsal pablogsal May 29, 2023

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Now that we are taking callables all of these can go :)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@pablogsal
pablogsal force-pushed the tokenizer_iter branch from 35328a4 to 1b8ff7e Compare May 29, 2023 20:32
@pablogsal
pythongh-105069: Add a readline-like callable to the tokenizer to con…
7caac01
…sume input iteratively

Signed-off-by: Pablo Galindo <[email protected]>
@pablogsal
pablogsal force-pushed the tokenizer_iter branch from 1b8ff7e to 7caac01 Compare May 29, 2023 21:21
pablogsal added 3 commits May 30, 2023 00:17
@pablogsal
fixup! pythongh-105069: Add a readline-like callable to the tokenizer…
8903d0d
… to consume input iteratively
@pablogsal
fixup! fixup! pythongh-105069: Add a readline-like callable to the to…
d370087
…kenizer to consume input iteratively
@pablogsal
fixup! fixup! fixup! pythongh-105069: Add a readline-like callable to…
2d6f0a6
… the tokenizer to consume input iteratively
@pablogsal pablogsal added the skip news label May 30, 2023
pablogsal
pablogsal commented May 30, 2023
View reviewed changes
Comment thread Lib/inspect.py
add(string)
if (string == ','):
add(' ')
clean_signature = ''.join(text).strip()

@pablogsal pablogsal May 30, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This change is because for some reason the inspect module is relying on the fact that if lines yielded by the generator do not end in \n then they are concatenated together, which is wrong because the contract says "should yield one line at a time" so if the line doesn't end in newline we add one always.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
lysnikolaou
lysnikolaou reviewed May 30, 2023
View reviewed changes

@lysnikolaou lysnikolaou left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Great job! 💯

A couple of comments and it's good to go!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Parser/tokenizer.c Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/tokenize.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

pablogsal added 2 commits May 30, 2023 17:12
@pablogsal
fixup! fixup! fixup! fixup! pythongh-105069: Add a readline-like call…
0935371
…able to the tokenizer to consume input iteratively
@pablogsal
fixup! fixup! fixup! fixup! fixup! pythongh-105069: Add a readline-li…
9990b7e
…ke callable to the tokenizer to consume input iteratively
@pablogsal

pablogsal commented May 30, 2023

Copy link
Copy Markdown
Member Author

Fixed the problems and added another test.

@lysnikolaou ready for another review!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pablogsal

pablogsal commented May 30, 2023

Copy link
Copy Markdown
Member Author

CC: @mgmacias95 wanna make a review?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@pablogsal
fixup! fixup! fixup! fixup! fixup! fixup! pythongh-105069: Add a read…
0598127
…line-like callable to the tokenizer to consume input iteratively
mgmacias95
mgmacias95 approved these changes May 30, 2023
View reviewed changes

@mgmacias95 mgmacias95 left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@pablogsal
pablogsal merged commit 9216e69 into python:main May 30, 2023
@pablogsal
pablogsal deleted the tokenizer_iter branch May 30, 2023 21:43
@bedevere-bot bedevere-bot removed the awaiting core review label May 30, 2023
@pablogsal pablogsal added awaiting core review needs backport to 3.12 only security fixes labels May 30, 2023
@miss-islington

miss-islington commented May 30, 2023

Copy link
Copy Markdown
Contributor

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington

miss-islington commented May 30, 2023

Copy link
Copy Markdown
Contributor

Sorry @pablogsal, I had trouble checking out the 3.12 backport branch.
Please retry by removing and re-adding the "needs backport to 3.12" label.
Alternatively, you can backport using cherry_picker on the command line.
cherry_picker 9216e69a87d16d871625721ed5a8aa302511f367 3.12

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington miss-islington assigned pablogsal May 30, 2023
@pablogsal pablogsal added needs backport to 3.12 only security fixes and removed needs backport to 3.12 only security fixes labels May 30, 2023
@miss-islington

miss-islington commented May 30, 2023

Copy link
Copy Markdown
Contributor

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 30, 2023
@pablogsal @miss-islington
pythongh-105069: Add a readline-like callable to the tokenizer to con…
6de88f2
…sume input iteratively (pythonGH-105070)

(cherry picked from commit 9216e69)

Co-authored-by: Pablo Galindo Salgado <[email protected]>
@bedevere-bot

bedevere-bot commented May 30, 2023

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-bot bedevere-bot removed the needs backport to 3.12 only security fixes label May 30, 2023
pablogsal added a commit that referenced this pull request May 31, 2023
@miss-islington @pablogsal
[3.12] gh-105069: Add a readline-like callable to the tokenizer to co…
c687946
…nsume input iteratively (GH-105070) (#105119)

gh-105069: Add a readline-like callable to the tokenizer to consume input iteratively (GH-105070)
(cherry picked from commit 9216e69)

Co-authored-by: Pablo Galindo Salgado <[email protected]>
@erlend-aasland erlend-aasland mentioned this pull request Jun 6, 2023
3.12 backport gh 105236 #105358
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@lysnikolaou lysnikolaou Awaiting requested review from lysnikolaou lysnikolaou is a code owner
1 more reviewer
@mgmacias95 mgmacias95 mgmacias95 approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@pablogsal pablogsal

Labels

awaiting core review skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@pablogsal @miss-islington @bedevere-bot @mgmacias95 @lysnikolaou
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.