[Import-SIG] improving ImportError
Erik Bray
erik.m.bray at gmail.com
Wed Sep 21 22:43:32 CEST 2011
On Wed, Sep 21, 2011 at 3:06 PM, Eric Snow <ericsnowcurrently at gmail.com> wrote:
> Armin Ronacher has an interesting blog post about some of the
> challenges of using Python's imports:
>
> http://lucumr.pocoo.org/2011/9/21/python-import-blackbox/
>
> In particular, his main point about "not found" vs. "broken" vs.
> "problem with inner import" got me thinking. Would it be a bad idea
> to split ImportError into more specific exceptions? I imagine that
> cataloguing the different causes of ImportError and how someone might
> react to those differently wouldn't be too hard...
>
> -eric
I agree, more granularity would be good. Would these additional
exceptions be subclasses of ImportError? It would be useful to be
able to start with just ImportError but then do different things for
ModuleNotFound as opposed to an import error due to a deeper
exception, perhaps with an easy way to access the original exception
that caused the ImportError as an attribute of the ImportError.
Erik
More information about the Import-SIG
mailing list