[issue15767] add ModuleNotFoundError
Eric Snow
report at bugs.python.org
Mon May 26 06:58:45 CEST 2014
Eric Snow added the comment:
Any chance we could revive ModuleNotFoundError? It's nice to be able to distinguish between the failure to *find* the module during import from other uses of ImportError. I'd definitely expect it to work the way Guido explained. Basically only importlib._bootstrap._find_and_load_unlocked() would raise ModuleNotFoundError (when _find_spec() returns None).
I've found the exception to be very useful while working on the importlib backport (https://bitbucket.org/ericsnowcurrently/importlib2). My desire for adding ModuleNotFoundError is unrelated to its internal use in importlib that motivated the original request (see msg182332).
Here's the signature:
ModuleNotFoundError(*args, name=None), inherits from ImportError
For reference, here's ImportError:
ImportError(*args, name=None, path=None)
ModuleNotFoundError would need to be exposed somewhere sensible since once people see in tracebacks they'll want to catch it. :) I'd expect that to be either in builtins or as importlib.ModuleNotFoundError. We may be able to get away with not adding it to builtins, but maybe it would still make sense.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15767>
_______________________________________
More information about the Python-bugs-list
mailing list