[Python-Dev] [Python-checkins] cpython: Close #17828: better handling of codec errors
Walter Dörwald
walter at livinglogic.de
Wed Nov 13 15:30:38 CET 2013
On 13.11.13 14:51, nick.coghlan wrote:
> http://hg.python.org/cpython/rev/854a2cea31b9
> changeset: 87084:854a2cea31b9
> user: Nick Coghlan <ncoghlan at 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.
I.e. BaseException would have an additional method annotate():
try:
dostuff(param)
except Exception as exc:
exc.annotate("while doing stuff with {}".format(param))
annotate() would simply append the message to an internal list attribute.
BaseException.__str__() could then use this to format an appropriate
exception message.
Servus,
Walter
More information about the Python-Dev
mailing list