Skip to content

bpo-37444: Update differing exception between builtins and importlib #14869

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

Merged

Conversation

nsiregar
Copy link
Contributor

@nsiregar nsiregar commented Jul 20, 2019

Imports now raise TypeError instead of ValueError for relative import failures. This makes things consistent between builtins.__import__ and importlib.__import__ as well as using a more natural import for the failure.

https://bugs.python.org/issue37444

Automerge-Triggered-By: @brettcannon

@nsiregar nsiregar force-pushed the bpo-37444-exceptions-builtin-importlib branch from 9592ccd to 314b4a4 Compare July 20, 2019 16:41
@brettcannon brettcannon added the type-bug An unexpected behavior, bug, or error label Jul 26, 2019
Copy link
Contributor

@ncoghlan ncoghlan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of minor documentation tweaks needed before this is ready to merge.

Copy link
Contributor

@ncoghlan ncoghlan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nsiregar! I went ahead and added some What's New entries directly, as it's possible there may be code out there that's calling this API directly and expecting ValueError.

@@ -1433,13 +1433,18 @@ an :term:`importer`.
``importlib.util.resolve_name('sys', __package__)`` without doing a
check to see if the **package** argument is needed.

:exc:`ValueError` is raised if **name** is a relative module name but
:exc:`ImportError` is raised if **name** is a relative module name but
package is a false value (e.g. ``None`` or the empty string).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
package is a false value (e.g. ``None`` or the empty string).
**package** is a false value (e.g. ``None`` or the empty string).

@brettcannon
Copy link
Member

I added a separate entry in What's New for the changes to builtins.__import__ and fixed a doc bug that I noticed on an unchanged line, otherwise LGTM! Thanks, @nsiregar !

I've set the PR to automerge once CI passes. If it doesn't then just let us know, @nsiregar .

@miss-islington
Copy link
Contributor

@nsiregar: Status check is done, and it's a failure ❌ .

1 similar comment
@miss-islington
Copy link
Contributor

@nsiregar: Status check is done, and it's a failure ❌ .

@nsiregar
Copy link
Contributor Author

nsiregar commented Aug 3, 2019

thanks @brettcannon , looks like CI is failing during documentation build and make patchcheck.

@miss-islington
Copy link
Contributor

@nsiregar: Status check is done, and it's a failure ❌ .

@nsiregar nsiregar force-pushed the bpo-37444-exceptions-builtin-importlib branch from 4b2f580 to b0c8536 Compare August 3, 2019 05:28
@miss-islington
Copy link
Contributor

@nsiregar: Status check is done, and it's a success ✅ .

@miss-islington miss-islington merged commit c5fa449 into python:master Aug 3, 2019
lisroach pushed a commit to lisroach/cpython that referenced this pull request Sep 10, 2019
…ythonGH-14869)

Imports now raise `TypeError` instead of `ValueError` for relative import failures. This makes things consistent between `builtins.__import__` and `importlib.__import__` as well as using a more natural import for the failure.


https://bugs.python.org/issue37444



Automerge-Triggered-By: @brettcannon
DinoV pushed a commit to DinoV/cpython that referenced this pull request Jan 14, 2020
…ythonGH-14869)

Imports now raise `TypeError` instead of `ValueError` for relative import failures. This makes things consistent between `builtins.__import__` and `importlib.__import__` as well as using a more natural import for the failure.


https://bugs.python.org/issue37444



Automerge-Triggered-By: @brettcannon
websurfer5 pushed a commit to websurfer5/cpython that referenced this pull request Jul 20, 2020
…ythonGH-14869)

Imports now raise `TypeError` instead of `ValueError` for relative import failures. This makes things consistent between `builtins.__import__` and `importlib.__import__` as well as using a more natural import for the failure.


https://bugs.python.org/issue37444



Automerge-Triggered-By: @brettcannon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants