Skip to content

bpo-21720: Restore the Python 2.7 logic in handling a fromlist.#4118

Merged
serhiy-storchaka merged 5 commits into
python:masterfrom
serhiy-storchaka:import-fromlist-check-type
Oct 26, 2017
Merged

bpo-21720: Restore the Python 2.7 logic in handling a fromlist.#4118
serhiy-storchaka merged 5 commits into
python:masterfrom
serhiy-storchaka:import-fromlist-check-type

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Oct 25, 2017

Copy link
Copy Markdown
Member

BytesWarning no longer emitted when the fromlist argument of
__import__() or the __all__ attribute of the module contain bytes
instances.

https://bugs.python.org/issue21720

BytesWarning no longer emitted when the fromlist argument of
__import__() or the __all__ attribute of the module contain bytes
instances.
@serhiy-storchaka serhiy-storchaka added the type-feature A feature request or enhancement label Oct 25, 2017
@serhiy-storchaka serhiy-storchaka requested a review from a team October 25, 2017 12:54

@brettcannon brettcannon left a comment

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.

A couple minor things, but all stuff I trust you to be able to handle, Serhiy. 😄

Comment thread Lib/importlib/_bootstrap.py Outdated
if x == '*':
if not recursive and hasattr(module, '__all__'):
_handle_fromlist(module, module.__all__, import_, True)

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.

Extraneous blank line.

Comment thread Lib/importlib/_bootstrap.py Outdated
where = "``from list''"
raise TypeError(f"Item in {where} must be str, "
f"not {type(x).__name__}")
if x == '*':

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.

elif

Comment thread Lib/importlib/_bootstrap.py Outdated


def _handle_fromlist(module, fromlist, import_):
def _handle_fromlist(module, fromlist, import_, recursive=False):

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.

recursive should probably be keyword-only, else it's ambiguous what _handle_fromlist(..., False) means.

@ncoghlan ncoghlan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM too. I'll close Berker's PR in favour of this one.

@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6.
🐍🍒⛏🤖

@miss-islington

Copy link
Copy Markdown
Contributor

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.6 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 41c56940c6edf3ea169332a6b039b6c8796f0475 3.6

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
…GH-4118) (#4128)

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants