On 14 November 2013 02:12, Nick Coghlan <ncogh...@gmail.com> wrote: > On 14 November 2013 00:30, Walter Dörwald <wal...@livinglogic.de> wrote: >> On 13.11.13 14:51, nick.coghlan wrote: >> >>> http://hg.python.org/cpython/rev/854a2cea31b9 >>> changeset: 87084:854a2cea31b9 >>> user: Nick Coghlan <ncogh...@gmail.com> >>> date: Wed Nov 13 23:49:21 2013 +1000 >>> summary: >>> Close #17828: better handling of codec errors >>> >>> - output type errors now redirect users to the type-neutral >>> convenience functions in the codecs module >>> - stateless errors that occur during encoding and decoding >>> will now be automatically wrapped in exceptions that give >>> the name of the codec involved >> >> >> Wouldn't it be better to add an annotation API to the exceptions classes? >> This would allow to annotate all exceptions without having to replace the >> exception object. > > There's a reason the C API for this is private - it's a band aid fix, > because solving it properly is hard :)
Note that the specific problem with just annotating the exception rather than a specific frame is that you lose the stack context for where the annotation occurred. The current chaining workaround doesn't just change the exception message, it also breaks the stack into two pieces (inside and outside the codec) that get displayed separately. Mostly though, it boils down to the fact that I'm far more comfortable changing codec exception stack trace details in some cases than I am proposing a new API for all exceptions this close to the Python 3.4 feature freeze. A more elegant (and comprehensive) solution as a PEP for 3.5 would certainly be a nice thing to have, but I think this is still much better than the 3.3 status quo. Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com