[Python-ideas] only raise ImportError out of imports

Eric Snow ericsnowcurrently at gmail.com
Tue Jul 31 08:14:30 CEST 2012


On Tue, Jul 31, 2012 at 12:00 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> 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.

Cool.  I'll have a look.

-eric



More information about the Python-ideas mailing list