generate_tokens(readline) must return bytes#3372
Merged
JelleZijlstra merged 1 commit intopython:masterfrom Oct 16, 2019
Merged
Conversation
blueyed
reviewed
Nov 22, 2019
| def detect_encoding(readline: Callable[[], bytes]) -> Tuple[str, Sequence[bytes]]: ... | ||
| def tokenize(readline: Callable[[], bytes]) -> Generator[TokenInfo, None, None]: ... | ||
| def generate_tokens(readline: Callable[[], str]) -> Generator[TokenInfo, None, None]: ... | ||
| def generate_tokens(readline: Callable[[], bytes]) -> Generator[TokenInfo, None, None]: ... # undocumented |
Contributor
There was a problem hiding this comment.
That's incorrect, isn't it?
https://github.com/python/cpython/blob/825358ab80d0e17e287c1e36a91dece0a97cb219/Lib/tokenize.py#L612-L618
Member
There was a problem hiding this comment.
Yes, confirmed in shell on 3.6. @srittau what was the basis for your change?
Contributor
There was a problem hiding this comment.
I've noticed that there are difference with py27 in this regard, so maybe it got confused?
Collaborator
Author
There was a problem hiding this comment.
No idea why I thought readline() should return bytes or why I even stumbled over this. I probably misread _tokenize().
srittau
added a commit
to srittau/typeshed
that referenced
this pull request
Nov 23, 2019
readline callback must return str, not bytes.
srittau
added a commit
that referenced
this pull request
Nov 23, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.