<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto">I’m a bit confused:<div><br></div><div>File names and the like are one thing, and the CONTENTS of files is quite another.</div><div><br></div><div>I get that there is theoretically a “default” encoding for the contents of text files, but that is SO likely to be wrong as to be ignorable.</div><div><br></div><div>open() already defaults to utf-8. Which is a fine default if you are going to have one, but it seems a bad idea to have it default to surrogateescape EVER, regardless of the locale or anything else.</div><div><br></div><div>If the file is binary, or a different encoding, or simply broken, it’s much better to get an encoding error as soon as possible.</div><div><br></div><div>Why does this have anything to do with the PEP?</div><div><br></div><div>Perhaps the issue of reading a filename from the system, writing it to a file, then reading it back in again. </div><div><br></div><div>I actually do that a lot — but mostly so I can pass that file to another system, so I really don’t want broken encoding in it anyway.</div><div><br></div><div>-CHB</div><div><br></div><div><br><div id="AppleMailSignature">Sent from my iPhone</div><div><br>On Dec 7, 2017, at 5:53 PM, Glenn Linderman <<a href="mailto:v+python@g.nevcal.com">v+python@g.nevcal.com</a>> wrote:<br><br></div><blockquote type="cite"><div>
  
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  
  
    <div class="moz-cite-prefix">On 12/7/2017 5:45 PM, Jonathan Goble
      wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:CAK256p1_3sZMWNpYkOJ2ivxYLj9iZH2-yAskYPEJ+Wynjaqo8w@mail.gmail.com">
      <div dir="ltr">
        <div class="gmail_quote">
          <div dir="ltr">On Thu, Dec 7, 2017 at 8:38 PM Glenn Linderman
            <<a href="mailto:v%2Bpython@g.nevcal.com">v+python@g.nevcal.com</a>>
            wrote:<br>
          </div>
          <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">If it were
            to be changed, one could add a text-mode option in 3.7, say
            "t" in the mode string, and a PendingDeprecationWarning for
            open calls without the specification of either t or b in the
            mode string.<br>
          </blockquote>
          <div><br>
          </div>
          <div>"t" is already supported in open()'s mode argument [1] as
            a way to explicitly request text mode, though it's
            essentially ignored right now since text is the default
            anyway. So since the option is already present, the only
            thing needed at this stage for your plan would be to begin
            deprecating not using it.</div>
          <div><br>
          </div>
          <div>*goes back to lurking*</div>
          <div><br>
          </div>
          <div>[1] <a href="https://docs.python.org/3/library/functions.html#open">https://docs.python.org/3/library/functions.html#open</a><br>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    Thanks for briefly de-lurking.<br>
    <br>
    So then for PEP 540... use surrogateescape immediately for t mode.<br>
    <br>
    Then, when the user encounters an encoding error, there would be
    three solutions: switch to t mode, explicitly switch to
    surrogateescape, or fix the locale.<br>
  

</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>Python-Dev mailing list</span><br><span><a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a></span><br><span><a href="https://mail.python.org/mailman/listinfo/python-dev">https://mail.python.org/mailman/listinfo/python-dev</a></span><br><span>Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/chris.barker%40noaa.gov">https://mail.python.org/mailman/options/python-dev/chris.barker%40noaa.gov</a></span><br></div></blockquote></div></body></html>