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

Victor Stinner victor.stinner at haypocalc.com
Fri Oct 21 22:07:55 CEST 2011


Le vendredi 29 juillet 2011 19:01:06, Guido van Rossum a écrit :
> On Fri, Jul 29, 2011 at 8:37 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> > On Sat, Jul 30, 2011 at 1:17 AM, Antoine Pitrou <solipsis at pitrou.net> 
wrote:
> >> On Thu, 28 Jul 2011 11:28:43 +0200
> >> 
> >> Victor Stinner <victor.stinner at haypocalc.com> wrote:
> >>> I will add your alternative to the PEP (except if you would like to do
> >>> that yourself?). If I understood correctly, you propose to:
> >>> 
> >>>   * rename codecs.open() to codecs.open_stream()
> >>>   * change codecs.open() to reuse open() (and so io.TextIOWrapper)
> >>> 
> >>> (and don't deprecate anything)
> >> 
> >> This may be an interesting approach. In a few years, we can evaluate
> >> whether users are calling open_stream(), and if there aren't any, we
> >> can deprecate the whole thing.
> > 
> > Indeed. I'm also heavily influenced by MAL's opinion on this
> > particular topic, so the fact he's OK with this approach counts for a
> > lot. It achieves the main benefit I'm interested in (transparently
> > migrating users of the codecs.open API to the new IO stack), while
> > paving the way for eliminating the redundancy at some point in the
> > future.
> 
> +1

I updated the PEP 400 to no longer *remove* deprecated functions in Python 
3.4. I don't like the idea of adding a *new* function (codecs.open_stream()) 
which emits a DeprecatingWarning. New functions are not supposed to be 
(indirectly) deprecated.

Short summary of the updated PEP 400:

 - patch codecs.open() to make it reuse TextIOWrapper to access text files 
(instead of Stream* classes)
 - instanciate Stream* classes emit a DeprecationWarning
 - that's all

So you can still get stream reader/writer using codecs.getreader() and 
codecs.getwriter() functions.

Victor


More information about the Python-Dev mailing list