[Python-Dev] An interesting exception handling quirk

Armin Rigo arigo at tunes.org
Sun Oct 20 08:08:53 CEST 2013


Hi Nick,

On Sat, Oct 19, 2013 at 1:41 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> recreating the *exact* exception subclass check from
> Python is actually difficult these days.

Can't it be done roughly like that?

   def __exit__(self, typ, val, tb):
        try:
            raise typ, val
        except self.exceptions:
            return True
        except:
            return False


A bientôt,

Armin.


More information about the Python-Dev mailing list