[Python-ideas] syntax to continue into the next subsequent except block
Chris Kaynor
ckaynor at zindagigames.com
Tue Sep 18 19:00:06 CEST 2012
On Mon, Sep 17, 2012 at 11:55 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> On Tue, Sep 18, 2012 at 11:08 AM, Stephen J. Turnbull
> <stephen at xemacs.org> wrote:
>> I agree with the suggestion that really we should fix up other Exceptions that are clearly quite heterogeneous by subclassing more precise exceptions from them.
>> But this isn't always possible, and of course may not be backward compatible.
If done well, it should be fully backwards compatible. There is not
reason that you cannot keep the errno (or however its named on the
specific exception class) while still subclassing the exception.
You could have issues with pickled exceptions if you add more details
to the exceptions, and it is not forward compatible: newer code that
gets the older form of exceptions is liable to break, without extreme
care to update the exceptions.
>> I don't know how to do it Pythonically, but it would be nice if there
>> were some way to "subclass Exceptions on the fly".
>
> Most likely, this will mean fixing the bug that means the ABC
> machinery is currently being ignored by the exception machinery. Then
> you can do whatever you want to reshape exception hierarchies.
One trick we've done at work in a few cases is to put a fairly thin
wrapper around the low-level apis that wrap the exceptions into
subclasses. Often, this can be implemented as a simple decorator that
then can be used on a series of functions easily.
>
> Cheers,
> Nick.
>
> --
> Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
More information about the Python-ideas
mailing list