Skip to content

bpo-40899: Document exception raised when module cannot be imported #27709

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1968,7 +1968,7 @@ are always available. They are listed here in alphabetical order.
This is an advanced function that is not needed in everyday Python
programming, unlike :func:`importlib.import_module`.

This function is invoked by the :keyword:`import` statement. It can be
This function is invoked by the :keyword:`import` statement. It can be
replaced (by importing the :mod:`builtins` module and assigning to
``builtins.__import__``) in order to change semantics of the
:keyword:`!import` statement, but doing so is **strongly** discouraged as it
Expand Down Expand Up @@ -2018,6 +2018,9 @@ are always available. They are listed here in alphabetical order.
object, the names to import are retrieved and assigned to their respective
names.

A :exc:`ImportError` exception can be raised if the module cannot be imported
successfully.

If you simply want to import a module (potentially within a package) by name,
use :func:`importlib.import_module`.

Expand Down
3 changes: 3 additions & 0 deletions Doc/library/importlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ Functions
need to call :func:`invalidate_caches` in order for the new module to be
noticed by the import system.

A :exc:`ImportError` exception can be raised if the module cannot be imported
successfully.

.. versionchanged:: 3.3
Parent packages are automatically imported.

Expand Down