[Import-SIG] improving ImportError

Brett Cannon brett at python.org
Wed Sep 21 23:16:05 CEST 2011


On Wed, Sep 21, 2011 at 13:43, Erik Bray <erik.m.bray at gmail.com> wrote:

> 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?


They would have to be or this is a non-starter.


>  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.


Python 3 already can chain exceptions (both explicitly and implicitly).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/import-sig/attachments/20110921/e88447e2/attachment.html>


More information about the Import-SIG mailing list