Skip to content
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

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

Merged

Conversation

serhiy-storchaka
Copy link
Member

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

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
Copy link
Member

@brettcannon brettcannon left a comment

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. 😄

if x == '*':
if not recursive and hasattr(module, '__all__'):
_handle_fromlist(module, module.__all__, import_, True)

Copy link
Member

Choose a reason for hiding this comment

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

Extraneous blank line.

where = "``from list''"
raise TypeError(f"Item in {where} must be str, "
f"not {type(x).__name__}")
if x == '*':
Copy link
Member

Choose a reason for hiding this comment

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

elif

@@ -994,7 +994,7 @@ def _gcd_import(name, package=None, level=0):
return _find_and_load(name, _gcd_import)


def _handle_fromlist(module, fromlist, import_):
def _handle_fromlist(module, fromlist, import_, recursive=False):
Copy link
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.

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.

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

@miss-islington
Copy link
Contributor

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

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