Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'sufficient': 0.05; 'url:pipermail': 0.05; '*not*': 0.07; 'subject:skip:c 10': 0.07; 'wrapper': 0.07; 'api': 0.09; 'missed': 0.09; 'python': 0.09; 'backwards': 0.09; 'objects.': 0.09; 'through.': 0.09; 'url:peps': 0.09; 'bug': 0.10; 'cc:addr:python-list': 0.10; 'advance': 0.10; 'suggest': 0.11; '(more': 0.16; 'api,': 0.16; 'bucket': 0.16; 'discussion.': 0.16; 'fixes.': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'url:patches': 0.16; 'wrote:': 0.17; 'fix': 0.17; 'module,': 0.17; 'url:dev': 0.17; '(in': 0.18; 'accepting': 0.18; 'are:': 0.20; 'all,': 0.21; 'bit': 0.21; 'fairly': 0.21; 'not,': 0.21; '2.x': 0.22; "i'd": 0.22; 'cc:2**0': 0.23; 'work.': 0.23; 'somebody': 0.23; 'patch': 0.24; 'raise': 0.24; 'cc:no real name:2**0': 0.24; 'specifically': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'looks': 0.26; 'separate': 0.27; 'attempting': 0.29; "d'aprano": 0.29; 'gather': 0.29; 'long.': 0.29; 'relies': 0.29; 'steven': 0.29; "they'll": 0.29; 'no,': 0.29; "i'm": 0.29; 'e.g.': 0.30; 'fri,': 0.30; 'mode': 0.30; 'feedback': 0.30; 'code': 0.31; 'url:python': 0.32; 'likely': 0.33; 'identified': 0.35; 'open': 0.35; 'there': 0.35; 'really': 0.36; 'but': 0.36; 'url:org': 0.36; 'email addr:python.org': 0.36; 'subject:with': 0.36; 'test': 0.36; 'problems': 0.36; 'enough': 0.36; 'being': 0.37; 'why': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'some': 0.38; 'received:10': 0.38; 'sure': 0.38; 'several': 0.39; 'header:Received:5': 0.40; 'url:mail': 0.40; 'skip:u 10': 0.60; 'chance': 0.61; "you'll": 0.62; 'provide': 0.62; 'series': 0.63; 'more': 0.63; 'here': 0.65; 'maintenance': 0.65; 'jul': 0.65; 'received:217': 0.68; 'direct': 0.69; 'internet': 0.71; 'received:10.10': 0.75; 'email name :python-dev': 0.84; 'indirect': 0.84; 'karl': 0.84; 'received:10.10.10': 0.84; 'ing': 0.91; 'step.': 0.91 X-Virus-Scanned: Debian amavisd-new at rhein.livinglogic.de Date: Tue, 10 Jul 2012 16:49:05 +0200 From: =?UTF-8?B?V2FsdGVyIETDtnJ3YWxk?= Organization: LivingLogic AG, Bayreuth/Germany User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: Steven D'Aprano Subject: Re: Issues with `codecs.register` and `codecs.CodecInfo` objects References: <4ff7a54c$0$29988$c3e8da3$5496439d@news.astraweb.com> In-Reply-To: <4ff7a54c$0$29988$c3e8da3$5496439d@news.astraweb.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 55 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1341933188 news.xs4all.nl 6880 [2001:888:2000:d::a6]:55457 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:25134 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