[Python-Dev] _not_found attribute on ImportError (original) (raw)

Brett Cannon brett at python.org
Mon Feb 11 15:44:47 CET 2013


On Mon, Feb 11, 2013 at 9:23 AM, Barry Warsaw <barry at python.org> wrote:

On Feb 11, 2013, at 09:23 PM, Nick Coghlan wrote:

>On Mon, Feb 11, 2013 at 8:58 PM, Chris Withers <chris at simplistix.co.uk> wrote: >> Have any other exceptions grown new attributes in Python 3? > >Off the top of my head, ImportError grew "name" and "path" attributes >in 3.3, everything grew cause, context and traceback >attributes in 3.0 and the suppresscontext attribute in 3.3. > >PEP 3151 may have moved a few attributes around in 3.3 as well. > >If there are any others, you'll need to trawl the What's New documents >looking for them. Those public attributes should be documented.

They are: http://docs.python.org/3.4/library/exceptions.html?highlight=importerror#ImportError

notfound should not be since it's an implementation detail.

Yep, hence the leading underscore.

Also, Brett has left little TODO easter eggs in the code which clearly indicate changes he plans for 3.4, although I don't know where the plans for ModuleNotFound are documented.

http://bugs.python.org/issue15767

Basically it's a matter of choosing ModuleNotFound vs. ModuleNotFoundError and then writing the code.

-Brett

In the meantime, I just ran a test against trunk, with the following change and nothing broke afaict. diff -r a79650aacb43 Lib/importlib/bootstrap.py --- a/Lib/importlib/bootstrap.py Mon Feb 11 13:33:00 2013 +0000 +++ b/Lib/importlib/bootstrap.py Mon Feb 11 09:16:51 2013 -0500 @@ -1640,6 +1640,7 @@ # TODO(brett): In Python 3.4, have import raise # ModuleNotFound and catch that. if getattr(exc, 'notfound', False): + del exc.notfound if exc.name == fromname: continue raise I won't commit this, but it really needs another hasattr() check to be completely valid. Cheers, -Barry


Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/brett%40python.org -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20130211/6348d823/attachment.html>



More information about the Python-Dev mailing list