Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #25134

Re: Issues with `codecs.register` and `codecs.CodecInfo` objects

Date 2012-07-10 16:49 +0200
From Walter Dörwald <walter@livinglogic.de>
Organization LivingLogic AG, Bayreuth/Germany
Subject Re: Issues with `codecs.register` and `codecs.CodecInfo` objects
References <mailman.1864.1341593739.4697.python-list@python.org> <4ff7a54c$0$29988$c3e8da3$5496439d@news.astraweb.com>
Newsgroups comp.lang.python
Message-ID <mailman.1987.1341933188.4697.python-list@python.org> (permalink)

Show all headers | View raw


On 07.07.12 04:56, Steven D'Aprano wrote:

> On Fri, 06 Jul 2012 12:55:31 -0400, Karl Knechtel wrote:
>
>> Hello all,
>>
>> While attempting to make a wrapper for opening multiple types of
>> UTF-encoded files (more on that later, in a separate post, I guess), I
>> ran into some oddities with the `codecs` module, specifically to do with
>> `.register` ing `CodecInfo` objects. I'd like to report a bug or
>> something, but there are several intertangled issues here and I'm not
>> really sure how to report it so I thought I'd open the discussion.
>> Apologies in advance if I get a bit rant-y, and a warning that this is
>> fairly long.
> [...]
>
> Yes, it's a strangely indirect API, and yes it looks like you have
> identified a whole bucket full of problems with it. And no, I don't know
> why that API was chosen.

This API was chosen for backwards compatibility reasons when incremental 
encoders/decoders were introduced (in 2006).

And yes: We missed the opportunity to clean that up to always use CodecInfo.

> Changing to a cleaner, more direct (sensible?) API would be a fairly big
> step. If you want to pursue this, the steps I recommend you take are:
>
> 1) understanding the reason for the old API (search the Internet
>     and particularly the python-dev@python.org archives);

See e.g. http://mail.python.org/pipermail/patches/2006-March/019122.html

> 2) have a plan for how to avoid breaking code that relies on the
>     existing API;
>
> 3) raise the issue on python-ideas@python.org to gather feedback
>     and see how much opposition or support it is likely to get;
>     they'll suggest whether a bug report is sufficient or if you'll
>     need a PEP;
>
>     http://www.python.org/dev/peps/
>
>
> If you can provide a patch and a test suite, you will have a much better
> chance of pushing it through. If not, you are reliant on somebody else
> who can being interested enough to do the work.
>
> And one last thing: any new functionality will simply *not* be considered
> for Python 2.x. Aim for Python 3.4, since the 2.x series is now in bug-
> fix only maintenance mode and the 3.3 beta is no longer accepting new
> functionality, only bug fixes.

Servus,
    Walter

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Issues with `codecs.register` and `codecs.CodecInfo` objects Karl Knechtel <zahlman@gmail.com> - 2012-07-06 12:55 -0400
  Re: Issues with `codecs.register` and `codecs.CodecInfo` objects Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-07 02:56 +0000
    Re: Issues with `codecs.register` and `codecs.CodecInfo` objects Walter Dörwald <walter@livinglogic.de> - 2012-07-10 16:49 +0200

csiph-web