| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Also, repair a couple of tests.
| is_package=is_package) | ||
| module.__spec__ = spec | ||
| module.__loader__ = loader | ||
| module.__loader__ = module.__loader__ = loader |
There was a problem hiding this comment.
Any specific reason to double-assign the same attribute?
Sorry, something went wrong.
There was a problem hiding this comment.
Nope, good catch! I thought I needed that in a previous commit, but I don't, so removed!
Sorry, something went wrong.
| 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). |
There was a problem hiding this comment.
s/pacakges/packages/
Sorry, something went wrong.
|
@warsaw: Please replace # with GH- in the commit message next time. Thanks! |
Sorry, something went wrong.
|
Thanks @warsaw for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6, 3.7. |
Sorry, something went wrong.
|
GH-5498 is a backport of this pull request to the 3.7 branch. |
Sorry, something went wrong.
* 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>
|
Sorry, @warsaw, I could not cleanly backport this to 3.6 due to a conflict. |
Sorry, something went wrong.
* 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>
* 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>
|
GH-5504 is a backport of this pull request to the 3.6 branch. |
Sorry, something went wrong.
…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>
…thonGH-5481) (python#5504)" This reverts commit a71397f.
…pace package ModuleSpec.origin was changed in python/cpython#5481 to be None for namespace packages.
Previously, when running `--pyargs pkg`, if you didn't have `pkg/__init__.py`, pytest would fail with `ERROR: module or package not found: pkg (missing __init__.py?)`. Now it's discovering the package and tests inside it correctly. If used in conjunction with =consider_namespace_packages= in config, the test modules get correct `__package__` and `__name__` attributes. Fixes: pytest-dev#478 Relevant: pytest-dev#10569 In addition, remove `"namespace"` origin handling -- this value isn't used since python 3.8. See python/cpython#5481 and https://docs.python.org/3/library/importlib.html#importlib.machinery.ModuleSpec.submodule_search_locations .
Previously, when running `--pyargs pkg`, if you didn't have `pkg/__init__.py`, pytest would fail with `ERROR: module or package not found: pkg (missing __init__.py?)`. Now it's discovering the package and tests inside it correctly. If used in conjunction with `consider_namespace_packages` in config, test modules get correct `__package__` and `__name__` attributes as well. Fixes: pytest-dev#478 Relevant: - pytest-dev#2371 - pytest-dev#10569 In addition, remove `"namespace"` origin handling -- this value isn't used since python 3.8. See python/cpython#5481 and https://docs.python.org/3/library/importlib.html#importlib.machinery.ModuleSpec.submodule_search_locations .
Previously, when running `--pyargs pkg`, if you didn't have `pkg/__init__.py`, pytest would fail with `ERROR: module or package not found: pkg (missing __init__.py?)`. Now it's discovering the package and tests inside it correctly. If used in conjunction with `consider_namespace_packages` in config, test modules get correct `__package__` and `__name__` attributes as well. Fixes: pytest-dev#478 Other relevant issues: - pytest-dev#2371 - pytest-dev#10569 In addition, remove `"namespace"` origin handling -- this value isn't used since python 3.8. See: - python/cpython#5481 - https://docs.python.org/3/library/importlib.html#importlib.machinery.ModuleSpec.submodule_search_locations .
Previously, when running `--pyargs pkg`, if you didn't have `pkg/__init__.py`, pytest would fail with `ERROR: module or package not found: pkg (missing __init__.py?)`. Now it's discovering the package and tests inside it correctly. If used in conjunction with `consider_namespace_packages` in config, test modules get correct `__package__` and `__name__` attributes as well. Fixes: pytest-dev#478 Other relevant issues: - pytest-dev#2371 - pytest-dev#10569 In addition, remove `"namespace"` origin handling -- this value isn't used since python 3.8. See: - python/cpython#5481 - https://docs.python.org/3/library/importlib.html#importlib.machinery.ModuleSpec.submodule_search_locations
Previously, when running `--pyargs pkg`, if you didn't have `pkg/__init__.py`, pytest would fail with `ERROR: module or package not found: pkg (missing __init__.py?)`. Now it's discovering the package and tests inside it correctly. If used in conjunction with `consider_namespace_packages` in config, test modules get correct `__package__` and `__name__` attributes as well. Fixes: pytest-dev#478 Other relevant issues: - pytest-dev#2371 - pytest-dev#10569 In addition, remove `"namespace"` origin handling -- this value isn't used since python 3.8. See: - python/cpython#5481 - https://docs.python.org/3/library/importlib.html#importlib.machinery.ModuleSpec.submodule_search_locations
…13426) Previously, when running `--pyargs pkg`, if you didn't have `pkg/__init__.py`, pytest would fail with `ERROR: module or package not found: pkg (missing __init__.py?)`. If used in conjunction with `consider_namespace_packages` in config, pytest discovers the package and tests inside it correctly. If used in conjunction with `consider_namespace_packages` in config, test modules get correct `__package__` and `__name__` attributes as well. In addition, remove `"namespace"` origin handling -- this value isn't used since python 3.8. See: - python/cpython#5481 - https://docs.python.org/3/library/importlib.html#importlib.machinery.ModuleSpec.submodule_search_locations Fixes #478 Fixes #2371 Fixes #10569
…ytest-dev#13426) Previously, when running `--pyargs pkg`, if you didn't have `pkg/__init__.py`, pytest would fail with `ERROR: module or package not found: pkg (missing __init__.py?)`. If used in conjunction with `consider_namespace_packages` in config, pytest discovers the package and tests inside it correctly. If used in conjunction with `consider_namespace_packages` in config, test modules get correct `__package__` and `__name__` attributes as well. In addition, remove `"namespace"` origin handling -- this value isn't used since python 3.8. See: - python/cpython#5481 - https://docs.python.org/3/library/importlib.html#importlib.machinery.ModuleSpec.submodule_search_locations Fixes pytest-dev#478 Fixes pytest-dev#2371 Fixes pytest-dev#10569
| Back | FazBrowse Home | New Git URL |
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