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-32303: Consistency fixes for namespace loaders #5481

Merged
merged 5 commits into from
Feb 2, 2018

Conversation

warsaw
Copy link
Member

@warsaw warsaw commented Feb 1, 2018

This branch actually fixes two inconsistencies for namespace package loaders.

I suppose it's possible that this will break existing code, but I'd argue that because current behavior runs counter to the documentation and makes no sense given the inconsistencies, it is better to fix them. I propose this change be applied to 3.7 and 3.6, although if you, my friendly reviewer, disagrees about 3.6, we can talk about it!

This isn't a security issue to back porting to 3.5 is off the table.

https://bugs.python.org/issue32303

@@ -441,7 +441,7 @@ def contents(self):
origin='does-not-exist',
is_package=is_package)
module.__spec__ = spec
module.__loader__ = loader
module.__loader__ = module.__loader__ = loader
Copy link
Member

Choose a reason for hiding this comment

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

Any specific reason to double-assign the same attribute?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, good catch! I thought I needed that in a previous commit, but I don't, so removed!

@@ -1291,7 +1291,7 @@ find and load modules.
Name of the place from which the module is loaded, e.g. "builtin" for
built-in modules and the filename for modules loaded from source.
Normally "origin" should be set, but it may be ``None`` (the default)
which indicates it is unspecified.
which indicates it is unspecified (e.g. for namespace pacakges).
Copy link
Member Author

Choose a reason for hiding this comment

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

s/pacakges/packages/

@warsaw warsaw merged commit bbbcf86 into python:master Feb 2, 2018
@bedevere-bot
Copy link

@warsaw: Please replace # with GH- in the commit message next time. Thanks!

@miss-islington
Copy link
Contributor

Thanks @warsaw for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6, 3.7.
🐍🍒⛏🤖

@warsaw warsaw deleted the nsloader branch February 2, 2018 20:16
@bedevere-bot
Copy link

GH-5498 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 2, 2018
* Make sure ``__spec__.loader`` matches ``__loader__`` for namespace packages.
* Make sure ``__spec__.origin` matches ``__file__`` for namespace packages.

https://bugs.python.org/issue32303
https://bugs.python.org/issue32305
(cherry picked from commit bbbcf86)

Co-authored-by: Barry Warsaw <barry@python.org>
@miss-islington
Copy link
Contributor

Sorry, @warsaw, I could not cleanly backport this to 3.6 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker bbbcf8693b876daae4469765aa62f8924f39a7d2 3.6

warsaw added a commit that referenced this pull request Feb 3, 2018
* Make sure ``__spec__.loader`` matches ``__loader__`` for namespace packages.
* Make sure ``__spec__.origin` matches ``__file__`` for namespace packages.

https://bugs.python.org/issue32303
https://bugs.python.org/issue32305
(cherry picked from commit bbbcf86)

Co-authored-by: Barry Warsaw <barry@python.org>
warsaw added a commit that referenced this pull request Feb 3, 2018
* Make sure ``__spec__.loader`` matches ``__loader__`` for namespace packages.
* Make sure ``__spec__.origin` matches ``__file__`` for namespace packages.

https://bugs.python.org/issue32303
https://bugs.python.org/issue32305.
(cherry picked from commit bbbcf86)

Co-authored-by: Barry Warsaw <barry@python.org>
@bedevere-bot
Copy link

GH-5504 is a backport of this pull request to the 3.6 branch.

warsaw added a commit that referenced this pull request Feb 3, 2018
…5504)

* Make sure ``__spec__.loader`` matches ``__loader__`` for namespace packages.
* Make sure ``__spec__.origin` matches ``__file__`` for namespace packages.

https://bugs.python.org/issue32303
https://bugs.python.org/issue32305.
(cherry picked from commit bbbcf86)

Co-authored-by: Barry Warsaw <barry@python.org>
@serhiy-storchaka serhiy-storchaka changed the title bpo-32303 - Consistency fixes for namespace loaders bpo-32303: Consistency fixes for namespace loaders Feb 19, 2018
warsaw added a commit to warsaw/cpython that referenced this pull request Feb 26, 2018
warsaw added a commit that referenced this pull request Feb 26, 2018
PCManticore added a commit to pylint-dev/astroid that referenced this pull request Jun 4, 2018
…pace package

ModuleSpec.origin was changed in python/cpython#5481
to be None for namespace packages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants