Suppressing Implicit Chained Exceptions (Python 3.0)

andrew cooke andrew at acooke.org
Wed Jul 1 13:42:06 EDT 2009


I have some (library) code where an exception is caught and, since the
underlying cause is rather obscure, a different exception is raised that
more clearly explains the issue to the caller.

However, when printed via format_exc(), this new exception still has the
old exception attached via the mechanism described at
http://www.python.org/dev/peps/pep-3134/ (this is Python 3.0).

Is there any simple way to stop this?  It's rather annoying and
misleading, as it exposes a lot of internal detail that the caller does
not understand or want.  This is marked as an "open issue" in the PEP
described above.

Thanks,
Andrew






More information about the Python-list mailing list