<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#330033">
    <div class="moz-cite-prefix">On 3/19/2016 2:37 PM, Serhiy Storchaka
      wrote:<br>
    </div>
    <blockquote cite="mid:nckgre$1e8$1@ger.gmane.org" type="cite">On
      19.03.16 19:36, Glenn Linderman wrote:
      <br>
      <blockquote type="cite">On 3/19/2016 8:19 AM, Serhiy Storchaka
        wrote:
        <br>
        <blockquote type="cite">On 16.03.16 08:03, Serhiy Storchaka
          wrote:
          <br>
          I just tested with Emacs, and it looks that when specify
          different
          <br>
          codings on two different lines, the first coding wins, but
          when
          <br>
          specify different codings on the same line, the last coding
          wins.
          <br>
          <br>
          Therefore current CPython behavior can be correct, and the
          regular
          <br>
          expression in PEP 263 should be changed to use greedy
          repetition.
          <br>
        </blockquote>
        <br>
        Just because emacs works that way (and even though I'm an emacs
        user),
        <br>
        that doesn't mean CPython should act like emacs.
        <br>
      </blockquote>
      <br>
      Yes. But current CPython works that way. The behavior of Emacs is
      the argument that maybe this is not a bug.
      <br>
    </blockquote>
    <br>
    If CPython properly handles the following line as having only one
    proper coding declaration (utf-8), then I might reluctantly agree
    that the behavior of Emacs might be a relevant argument.  Otherwise,
    vehemently not relevant.<br>
    <br>
      # -*- coding: utf-8 -*- this file does not use coding: latin-1<br>
    <br>
    <br>
    <blockquote cite="mid:nckgre$1e8$1@ger.gmane.org" type="cite">
      <br>
      <blockquote type="cite">(4) there is no benefit to specifying the
        coding twice on a line, it
        <br>
        only adds confusion, whether in CPython, emacs, or vim.
        <br>
        (4a) Here's an untested line that emacs would interpret as
        utf-8, and
        <br>
        CPython with the greedy regulare expression would interpret as
        latin-1,
        <br>
        because emacs looks only between the -*- pair, and CPython
        ignores that.
        <br>
           # -*- coding: utf-8 -*- this file does not use coding:
        latin-1
        <br>
      </blockquote>
      <br>
      Since Emacs allows to specify the coding twice on a line, and this
      can be ambiguous, and CPython already detects some ambiguous
      situations (UTF-8 BOM and non-UTF-8 coding cookie), it may be
      worth to add a check that the coding is specified only once on a
      line.
      <br>
    </blockquote>
    <br>
    Diagnosing ambiguous conditions, even including my example above,
    might be useful... for a few files... is it worth the effort? What %
    of .py sources have coding specifications? What % of those have two?<br>
  </body>
</html>