<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Dec 7, 2017 at 3:02 PM, Victor Stinner <span dir="ltr"><<a href="mailto:victor.stinner@gmail.com" target="_blank">victor.stinner@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">2017-12-06 5:07 GMT+01:00 INADA Naoki <<a href="mailto:songofacandy@gmail.com">songofacandy@gmail.com</a>>:<br>
> And opening binary file without "b" option is very common mistake of new<br>
> developers.  If default error handler is surrogateescape, they lose a chance<br>
> to notice their bug.<br>
<br>
</span>To come back to your original point, I didn't know that it was a<br>
common mistake to open binary files in text mode.<br></blockquote><div><br></div><div>It probably is because in Python 2 it makes no difference on UNIX, and on Windows the only difference is that binary mode preserves \r.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Honestly, I didn't try recently. How does Python behave when you do that?<br>
<br>
Is it possible to write a full binary parser using the text mode? You<br>
should quickly get issues pointing you to your mistake, no?<span class="HOEnZb"></span><br></blockquote></div></div><div class="gmail_extra"><br></div><div class="gmail_extra">You will quickly get decoding errors, and that is INADA's point. (Unless you use encoding='Latin-1'.) His worry is that the surrogateescape error handler makes it so that you won't get decoding errors, and then the failure mode is much harder to debug.<br clear="all"></div><div class="gmail_extra"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido" target="_blank">python.org/~guido</a>)</div>
</div></div>