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
Relative imports use resolve_name to get the absolute target name,
which first seeks the current module's absolute package name from the globals:
If package (and spec.parent) are missing then
import uses name, truncating the last segment if
the module is a submodule rather than a package init.py
(which it guesses from whether path is defined).
The name attempt should fail if there is no parent package (top level modules),
if name is 'main' (-m entry points), or both (scripts).
That is, if both name has no subcomponents and the module does not seem
to be a package init module then import should fail..
(cherry picked from commit 92420b3)
Relative imports use resolve_name to get the absolute target name,
which first seeks the current module's absolute package name from the globals:
If __package__ (and __spec__.parent) are missing then
import uses __name__, truncating the last segment if
the module is a submodule rather than a package __init__.py
(which it guesses from whether __path__ is defined).
The __name__ attempt should fail if there is no parent package (top level modules),
if __name__ is '__main__' (-m entry points), or both (scripts).
That is, if both __name__ has no subcomponents and the module does not seem
to be a package __init__ module then import should fail..
(cherry picked from commit 92420b3)
Co-authored-by: Ben Lewis <benjimin@users.noreply.github.com>
…ythonGH-15913)
Relative imports use resolve_name to get the absolute target name,
which first seeks the current module's absolute package name from the globals:
If __package__ (and __spec__.parent) are missing then
import uses __name__, truncating the last segment if
the module is a submodule rather than a package __init__.py
(which it guesses from whether __path__ is defined).
The __name__ attempt should fail if there is no parent package (top level modules),
if __name__ is '__main__' (-m entry points), or both (scripts).
That is, if both __name__ has no subcomponents and the module does not seem
to be a package __init__ module then import should fail..
(cherry picked from commit 92420b3)
Co-authored-by: Ben Lewis <benjimin@users.noreply.github.com>
(cherry picked from commit 0a6693a)
Co-authored-by: Brett Cannon <54418+brettcannon@users.noreply.github.com>
)
Relative imports use resolve_name to get the absolute target name,
which first seeks the current module's absolute package name from the globals:
If __package__ (and __spec__.parent) are missing then
import uses __name__, truncating the last segment if
the module is a submodule rather than a package __init__.py
(which it guesses from whether __path__ is defined).
The __name__ attempt should fail if there is no parent package (top level modules),
if __name__ is '__main__' (-m entry points), or both (scripts).
That is, if both __name__ has no subcomponents and the module does not seem
to be a package __init__ module then import should fail..
(cherry picked from commit 92420b3)
Co-authored-by: Ben Lewis <benjimin@users.noreply.github.com>
(cherry picked from commit 0a6693a)
Co-authored-by: Brett Cannon <54418+brettcannon@users.noreply.github.com>
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.
Relative imports use resolve_name to get the absolute target name,
which first seeks the current module's absolute package name from the globals:
If package (and spec.parent) are missing then
import uses name, truncating the last segment if
the module is a submodule rather than a package init.py
(which it guesses from whether path is defined).
The name attempt should fail if there is no parent package (top level modules),
if name is 'main' (-m entry points), or both (scripts).
That is, if both name has no subcomponents and the module does not seem
to be a package init module then import should fail..
(cherry picked from commit 92420b3)
Co-authored-by: Ben Lewis benjimin@users.noreply.github.com
https://bugs.python.org/issue37409
Automerge-Triggered-By: @brettcannon