bpo-21720: Restore the Python 2.7 logic in handling a fromlist.#4118
Merged
serhiy-storchaka merged 5 commits intoOct 26, 2017
Merged
Conversation
BytesWarning no longer emitted when the fromlist argument of __import__() or the __all__ attribute of the module contain bytes instances.
brettcannon
approved these changes
Oct 25, 2017
brettcannon
left a comment
Member
There was a problem hiding this comment.
A couple minor things, but all stuff I trust you to be able to handle, Serhiy. 😄
| if x == '*': | ||
| if not recursive and hasattr(module, '__all__'): | ||
| _handle_fromlist(module, module.__all__, import_, True) | ||
|
|
| where = "``from list''" | ||
| raise TypeError(f"Item in {where} must be str, " | ||
| f"not {type(x).__name__}") | ||
| if x == '*': |
|
|
||
|
|
||
| def _handle_fromlist(module, fromlist, import_): | ||
| def _handle_fromlist(module, fromlist, import_, recursive=False): |
Member
There was a problem hiding this comment.
recursive should probably be keyword-only, else it's ambiguous what _handle_fromlist(..., False) means.
ncoghlan
approved these changes
Oct 26, 2017
ncoghlan
left a comment
Contributor
There was a problem hiding this comment.
LGTM too. I'll close Berker's PR in favour of this one.
Contributor
|
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6. |
Contributor
|
Sorry, @serhiy-storchaka, I could not cleanly backport this to |
serhiy-storchaka
added a commit
to serhiy-storchaka/cpython
that referenced
this pull request
Oct 26, 2017
…pythonGH-4118) BytesWarning no longer emitted when the fromlist argument of __import__() or the __all__ attribute of the module contain bytes instances.. (cherry picked from commit 41c5694)
serhiy-storchaka
added a commit
that referenced
this pull request
Oct 26, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BytesWarning no longer emitted when the fromlist argument of
__import__()or the__all__attribute of the module contain bytesinstances.
https://bugs.python.org/issue21720