<p dir="ltr"><br>
On 15 Nov 2013 09:11, "Nick Coghlan" <<a href="mailto:ncoghlan@gmail.com">ncoghlan@gmail.com</a>> wrote:<br>
><br>
><br>
> On 15 Nov 2013 08:42, "Victor Stinner" <<a href="mailto:victor.stinner@gmail.com">victor.stinner@gmail.com</a>> wrote:<br>
> ><br>
> > Oh, I forgot to mention that I sent this email in reaction to this issue:<br>
> ><br>
> > <a href="http://bugs.python.org/issue19585">http://bugs.python.org/issue19585</a><br>
> ><br>
> > Modifying the critical PyFrameObject because the codecs API raises<br>
> > surprising errors doesn't sound correct. I prefer to fix how codecs<br>
> > are used, than modifying the PyFrameObject.<br>
> ><br>
> > For more information, see the issue #7475 which a long history (4<br>
> > years) and many messages. Martin von Loewis wrote "I would still be<br>
> > opposed to such a change, and I think it needs a PEP." and I still<br>
> > agree with him on this point. Because they are different opinions and<br>
> > no consensus, a PEP is required to explain why we took this decision<br>
> > and list rejected alternatives.<br>
> ><br>
> > <a href="http://bugs.python.org/issue7475">http://bugs.python.org/issue7475</a><br>
><br>
> Martin wrote that before it was pointed out there were existing functions to handle the problem (I was asking for a PEP back then, too).<br>
><br>
> I posted my plan for dealing with this months ago without receiving any complaints, and I'm annoyed you waited until I had actually followed through and implemented it to complain about it and ask for Python 3's binary codec support to stay broken instead :P</p>

<p dir="ltr">Something I *would* be entirely happy to do is write a retroactive PEP after beta 1  is out the door, explaining the history of this issue in a more coherent form than the comment history on issue 7475 and the many child issues it spawned.</p>

<p dir="ltr">This would also provide a better launching point for other enhancements in Python 3.5 (frame annotations to remove the need for the exception chaining hack and better input validation mechanisms for codecs that allow the convenience methods to check that case explicitly rather than relying on the exception chaining).</p>

<p dir="ltr">Cheers,<br>
Nick.</p>
<p dir="ltr">><br>
> (Starting a new thread instead of replying to the one where I specifically asked about taking the next step does nothing to improve my mood)<br>
><br>
> Regards,<br>
> Nick.<br>
><br>
> ><br>
> > Victor<br>
> ><br>
> > 2013/11/14 Victor Stinner <<a href="mailto:victor.stinner@gmail.com">victor.stinner@gmail.com</a>>:<br>
> > > Hi,<br>
> > ><br>
> > > I saw that Nick Coghlan documented codecs.encode() and<br>
> > > codecs.decode(), and changed the exception raised when codecs like<br>
> > > rot_13 are used on bytes.decode() and str.encode().<br>
> > ><br>
> > > I don't like the functions codecs.encode() and codecs.decode() because<br>
> > > the type of the result depends on the encoding (second parameter). We<br>
> > > try to avoid this in Python.<br>
> > ><br>
> > > I would prefer to split the registry of codecs to have 3 registries:<br>
> > ><br>
> > > - "encoding" (a better name can found): encode str=>bytes, decode bytes=>str<br>
> > > - bytes: encode bytes=>bytes, decode bytes=>bytes<br>
> > > - str:  encode str=>str, decode str=>str<br>
> > ><br>
> > > And add transform() and untransform() methods to bytes and str types.<br>
> > > In practice, it might be same codecs registry for all codecs just with<br>
> > > a new attribute.<br>
> > ><br>
> > > Examples:<br>
> > ><br>
> > > - utf8: encoding<br>
> > > - zlib: bytes<br>
> > > - rot13: str<br>
> > ><br>
> > > The result type of bytes.transform/untransform would be bytes, and the<br>
> > > result type of str.transform/untransform would be str.<br>
> > ><br>
> > > I don't know which exception should be raised when a codec is used in<br>
> > > the wrong method. LookupError? TypeError "codec xxx cannot be used<br>
> > > with method xxx.xx"? Something else?<br>
> > ><br>
> > > codecs.encode/decode() documentation should be removed. The functions<br>
> > > should be kept, just in case if someone uses them.<br>
> > ><br>
> > > Victor<br>
> > _______________________________________________<br>
> > Python-Dev mailing list<br>
> > <a href="mailto:Python-Dev@python.org">Python-Dev@python.org</a><br>
> > <a href="https://mail.python.org/mailman/listinfo/python-dev">https://mail.python.org/mailman/listinfo/python-dev</a><br>
> > Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/ncoghlan%40gmail.com">https://mail.python.org/mailman/options/python-dev/ncoghlan%40gmail.com</a><br>
</p>