-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Double coding cookie #70768
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
Comments
When Python source file contains double coding cookies on different lines, the first wins. When it contains double coding cookies on the same line, the last wins. PEP-263 was sufficiently vague about this. Now this is clarified (22490711c870). The first coding cookie should always win. Proposed patch fixes Python tokenizer, the tokenize module, and other places. Tests are taken from bpo-25643. |
I just tested with Emacs, and it looks that when specify different codings on two different lines, the first coding wins, but when specify different codings on the same line, the last coding wins. Therefore current CPython behavior can be correct, and the regular expression in PEP-263 should be changed to use greedy repetition. |
Do you have write permission to the PEP? Just update it. |
Yes, I have. But I were not sure what behavior should be correct in Python. On one side, always choosing the first declaration (on the same or on different lines) looks more consistent. On other side, current behavior was in CPython from the initial implementing PEP-263 in bpo-526840 and it matches Emacs behavior (if I understand this correctly). I can update the regular expression, but may be this obscure corner case needs the verbal explanation. |
Right. Please go ahead with both. I am fine with defining the current --Guido (mobile)
|
New changeset 23a7481eafd4 by Serhiy Storchaka in branch 'default': |
New changeset 1c44cea2ea8f by Serhiy Storchaka in branch '3.5': New changeset 8506d127d482 by Serhiy Storchaka in branch '2.7': New changeset e86cd4a872b8 by Serhiy Storchaka in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: