[Python-Dev] What does a double coding cookie mean?
Guido van Rossum
guido at python.org
Wed Mar 16 20:29:58 EDT 2016
I've updated the PEP. Please review. I decided not to update the
Unicode howto (the thing is too obscure). Serhiy, you're probably in a
better position to fix the code looking for cookies to pick the first
one if there are two on the same line (or do whatever you think should
be done there).
Should we recommend that everyone use tokenize.detect_encoding()?
On Wed, Mar 16, 2016 at 5:05 PM, Guido van Rossum <guido at python.org> wrote:
> On Wed, Mar 16, 2016 at 12:59 AM, M.-A. Lemburg <mal at egenix.com> wrote:
>> The only reason to read up to two lines was to address the use of
>> the shebang on Unix, not to be able to define two competing
>> source code encodings :-)
> I know. I was just surprised that the PEP was sufficiently vague about
> it that when I found that mypy picked the second if there were two, I
> couldn't prove to myself that it was violating the PEP. I'd rather
> clarify the PEP than rely on the reasoning presented earlier here.
> I don't like erroring out when there are two different cookies on two
> lines; I feel that the spirit of the PEP is to read up to two lines
> until a cookie is found, whichever comes first.
> I will update the regex in the PEP too (or change the wording to avoid "match").
> I'm not sure what to do if there are two cooking on one line. If
> CPython currently picks the latter we may want to preserve that
> Should we recommend that everyone use tokenize.detect_encoding()?
> --Guido van Rossum (python.org/~guido)
--Guido van Rossum (python.org/~guido)
More information about the Python-Dev