[Python-ideas] only raise ImportError out of imports

Nick Coghlan ncoghlan at gmail.com
Tue Jul 31 08:00:44 CEST 2012


On Tue, Jul 31, 2012 at 3:49 PM, Eric Snow <ericsnowcurrently at gmail.com> wrote:
> The main benefit of this change would be to isolate errors during
> import to the module where they happen.  The main challenge would be
> with backward compatibility, so I won't hold my breath to see this in
> Python 3.
>
> While all feedback is welcome, I'd particularly like to hear from
> those that actually use non-ImportError exceptions that come out of
> the import statement.  Thanks!

The problem specifically with doing this for SyntaxError is that you
would break every interactive interpreter out there (including the
default one). They rely on seeing the SyntaxError directly in order to
highlight the offending piece of syntax.

Also dig into pkgutil - that broke when I started tinkering with this
kind of thing while migrating it over to using importlib.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia



More information about the Python-ideas mailing list