bpo-25324: copy tok_name before changing it#1608
Conversation
|
@albertjan, thanks for your PR! By analyzing the history of the files in this pull request, we identified @serhiy-storchaka, @1st1 and @tpn to be potential reviewers. |
|
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately our records indicate you have not signed the CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. Thanks again to your contribution and we look forward to looking at it! |
vstinner
left a comment
There was a problem hiding this comment.
I'm not sure that it's the right way to fix the issue: see http://bugs.python.org/issue25324 discussion. I also have comments on the change itself, but I will want until we agree on the way to fix the issue before reviewing the change.
|
Due to a new release of Sphinx, we had to fix the documentation to build on Travis again. Please do a merge to get these changes to help get Travis passing on your PR. |
There was a problem hiding this comment.
Please don't change ERRORTOKEN value.
There was a problem hiding this comment.
Please copy token.h comment here.
|
Updated the PR. comments are now copied from token.h to token.py automatically. And I moved ERRORTOKEN back to where it was. |
vstinner
left a comment
There was a problem hiding this comment.
LGTM, but I added a new (last I hope) serie of nitpicking comments :-p
There was a problem hiding this comment.
This change is not PEP 8 compliant :-)
There was a problem hiding this comment.
This string emits:
<stdin>:1: DeprecationWarning: invalid escape sequence \s
I suggest to always use raw strings for regular expressions.
There was a problem hiding this comment.
I would prefer to use val here, but set prev_val after the tokens assignement. Here we use the current value, not the previous value.
There was a problem hiding this comment.
"prev_val is not None" to support prev_val == 0 (ENDMARKER = 0).
There was a problem hiding this comment.
nitpick: i suggest to rename the variable "comment".
There was a problem hiding this comment.
nitpick: I suggest to rename "val" to "key" to be more consistent.
|
This should address your comments. Thanks for taking the time to review my PR. |
vstinner
left a comment
There was a problem hiding this comment.
LGTM. I will merge the change once tests pass.
|
Please wait with merging. I'm finishing my patch for generating |
Wait? Do you expect conflicts? |
|
Yes, conflicts, and maybe this will lead to redesigning both patches. |
There was a problem hiding this comment.
and: lower case
in token.py: in the token module
import tokenize.py: import the tokenize module.
|
Should I do a merge or a rebase to resolve the conflicts? |
As you want. |
f02a84e to
e7113fa
Compare
| Core and Builtins | ||
| ----------------- | ||
|
|
||
| - bpo-25324: Tokens needed for parsing in python moved to C. ``COMMENT``, |
| tokens, and :data:`AWAIT` and :data:`ASYNC` will be removed. | ||
|
|
||
| .. versionchanged:: 3.7 | ||
| Added :data:`COMMENT`, :data:`NL` and :data:`ENCODING`. To bring |
There was a problem hiding this comment.
Isn't a period is redundant here?
| .. versionchanged:: 3.7 | ||
| Added :data:`COMMENT`, :data:`NL` and :data:`ENCODING`. To bring | ||
| the tokens in the C code in line with the tokens needed in | ||
| tokenize.py. These tokens aren't used by the C tokenizer. No newline at end of file |
There was a problem hiding this comment.
tokenize.py -> the :mod:`tokenize` module
|
LGTM. Thanks @albertjan! |
|
Nevermind @albertjan, looks like the issue I described here was caused by a merge issue. Thanks anyway :) |
Saw this open bug report, and since I was looking at tokenize.py anyway. I figured I address it.
This may catch people off guard though because they may be relying on
tok_namecontainingENCODING,COMMENTandNL. 🤷♂️