Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Artificial newlines show in the "line" attribute of tokens in the tokenizer module #105564

Closed
pablogsal opened this issue Jun 9, 2023 · 1 comment

Comments

@pablogsal
Copy link
Member

pablogsal commented Jun 9, 2023

Example:

from tokenize import generate_tokens
from io import StringIO
import pprint
pprint.pprint(list(generate_tokens(StringIO('a').readline)))

prints:

[TokenInfo(type=1 (NAME), string='a', start=(1, 0), end=(1, 1), line='a\n'),
 TokenInfo(type=4 (NEWLINE), string='', start=(1, 1), end=(1, 2), line='a'),
 TokenInfo(type=0 (ENDMARKER), string='', start=(2, 0), end=(2, 0), line='')]

Linked PRs

@pablogsal
Copy link
Member Author

pablogsal added a commit to pablogsal/cpython that referenced this issue Jun 9, 2023
…ute of tokens

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
pablogsal added a commit to pablogsal/cpython that referenced this issue Jun 9, 2023
…ute of tokens

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
pablogsal added a commit to pablogsal/cpython that referenced this issue Jun 9, 2023
…ute of tokens

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jun 9, 2023
…ute of tokens (pythonGH-105565)

(cherry picked from commit d7f46bc)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
pablogsal added a commit that referenced this issue Jun 9, 2023
…bute of tokens (GH-105565) (#105579)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant