Skip to content

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

Merged
miss-islington merged 10 commits intopython:masterfrom
nsiregar:bpo-37444-exceptions-builtin-importlib
Aug 3, 2019
Merged

bpo-37444: Update differing exception between builtins and importlib#14869
miss-islington merged 10 commits intopython:masterfrom
nsiregar:bpo-37444-exceptions-builtin-importlib

Conversation

@nsiregar
Copy link
Copy Markdown
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
Comment thread Lib/importlib/util.py
Comment thread Misc/NEWS.d/next/Core and Builtins/2019-07-20-22-34-42.bpo-37444.UOd3Xs.rst Outdated
@brettcannon brettcannon added the type-bug An unexpected behavior, bug, or error label Jul 26, 2019
Copy link
Copy Markdown
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.

Comment thread Doc/library/importlib.rst
Comment thread Misc/NEWS.d/next/Core and Builtins/2019-07-20-22-34-42.bpo-37444.UOd3Xs.rst Outdated
Copy link
Copy Markdown
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.

Comment thread Doc/library/importlib.rst Outdated

: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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

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

1 similar comment
@miss-islington
Copy link
Copy Markdown
Contributor

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

@nsiregar
Copy link
Copy Markdown
Contributor Author

nsiregar commented Aug 3, 2019

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

@miss-islington
Copy link
Copy Markdown
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
Copy Markdown
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