[Python-Dev] Status of the PEP 400? (deprecate codecs.StreamReader/StreamWriter) (original) (raw)

Guido van Rossum guido at python.org
Thu Jul 28 04:05:18 CEST 2011


On Wed, Jul 27, 2011 at 6:00 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:

On Thu, Jul 28, 2011 at 9:38 AM, Guido van Rossum <guido at python.org> wrote:

Users of codecs.open() or users of codecs.Stream* classes?

I would think both. Is there any reason to continue using codecs.open()? It's the easiest way to write Unicode friendly code that spans both 2.x and 3.x.

Even on 2.6, where the io module exists?

The problem is that naive 2.x code will migrate to the optimised IO stack automatically on the 2.x -> 3.x transition, while code that tried to do the right thing has to be changed manually (either in 3.x only, or by switching to the io module for 2.x as well) in order to adjust for the differences in argument order.

The idea behind changing codecs.open to be a wrapper around io.open was to allow such code to switch to the new optimised IO stack as easily as code that just uses the open builtin. If it's acceptable for the builtin behaviour to change (far more substantially), why not change codecs.open as well?

Aren't the cases different? Using built-in open() just means you want to open a file in the default way. Using codecs.open() presumably means that you've thought about Unicode.

TBH, I said I was only -0 on the PEP, and if the stream returned by codecs.open() in 3.3 is sufficiently compatible with the stream returned the same function returns in 3.2, I am okay with it. (Except I also want you to cut a trillion dollars from the non-military budget, without raising taxes. :-)

-- --Guido van Rossum (python.org/~guido)



More information about the Python-Dev mailing list