-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
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
Changes from 5 commits
426ad0b
5cf6217
58ff0b0
2f810f8
1a962e3
c494ed6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
@@ -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. | ||
|
Comment on lines
+2021
to
+2022
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I like this wording - what do you mean "can be raised", it sounds like it is possible for import to fail and not raise an exception.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It means arbitrary exceptions can also be raised.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand the intent, but I don't think that's the only possible interpretation of the current wording.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just found out that #94662 is also doing the same thing. Would you prefer that one? |
||
|
|
||
| If you simply want to import a module (potentially within a package) by name, | ||
| use :func:`importlib.import_module`. | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.