Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #55486
| References | <524ec8fe$0$29984$c3e8da3$5496439d@news.astraweb.com> |
|---|---|
| Date | 2013-10-05 03:22 +1000 |
| Subject | Re: API for custom Unicode error handlers |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.727.1380907377.18130.python-list@python.org> (permalink) |
On Fri, Oct 4, 2013 at 11:56 PM, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: > Should the module holding the error handlers automatically register them? > In other words, if I do: > > import error_handlers > > just importing it will have the side-effect of registering the error > handlers. Normally, I dislike imports that have side-effects of this > sort, but I'm not sure that the alternative is better, that is, to put > responsibility on the caller to register some, or all, of the handlers: > > import error_handlers > error_handlers.register(error_handlers.namereplace_errors) > error_handlers.register_all() Caveat: I don't actually use codecs much, so I don't know the specifics. I'd be quite happy with importing having a side-effect here. If you import a module that implements a numeric type, it should immediately register itself with the Numeric ABC, right? This is IMO equivalent to that. > As far as I know, there is no way to find out what error handlers are > registered, and no way to deregister one after it has been registered. The only risk that I see is of an accidental collision. Having a codec registered that you don't use can't hurt (afaik). Is there any mechanism for detecting a name collision? If not, I wouldn't worry about it. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
API for custom Unicode error handlers Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-04 13:56 +0000 Re: API for custom Unicode error handlers Chris Angelico <rosuav@gmail.com> - 2013-10-05 03:22 +1000 Re: API for custom Unicode error handlers Ethan Furman <ethan@stoneleaf.us> - 2013-10-04 11:05 -0700 Re: API for custom Unicode error handlers Serhiy Storchaka <storchaka@gmail.com> - 2013-10-04 22:08 +0300 Re: API for custom Unicode error handlers Serhiy Storchaka <storchaka@gmail.com> - 2013-10-04 22:35 +0300 Re: API for custom Unicode error handlers Terry Reedy <tjreedy@udel.edu> - 2013-10-04 18:44 -0400
csiph-web