mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #1559549: Add 'name' and 'path' attributes to ImportError.
Currently import does not use these attributes as they are planned for use by importlib (which will be another commit). Thanks to Filip Gruszczyński for the initial patch and Brian Curtin for refining it.
This commit is contained in:
parent
f50b38a11f
commit
79ec55e980
6 changed files with 192 additions and 3 deletions
|
@ -159,6 +159,14 @@ The following exceptions are the exceptions that are usually raised.
|
|||
Raised when an :keyword:`import` statement fails to find the module definition
|
||||
or when a ``from ... import`` fails to find a name that is to be imported.
|
||||
|
||||
The :attr:`name` and :attr:`path` attributes can be set using keyword-only
|
||||
arguments to the constructor. When set they represent the name of the module
|
||||
that was attempted to be imported and the path to any file which triggered
|
||||
the exception, respectively.
|
||||
|
||||
.. versionchanged:: 3.3
|
||||
Added the :attr:`name` and :attr:`path` attributes.
|
||||
|
||||
|
||||
.. exception:: IndexError
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue