Skip to content

[3.6] bpo-30891: Fix again importlib _find_and_load() (#2665) #2801

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

Merged
merged 1 commit into from
Jul 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Lib/importlib/_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,6 @@ def spec_from_loader(name, loader, *, origin=None, is_package=None):
return ModuleSpec(name, loader, origin=origin, is_package=is_package)


_POPULATE = object()


def _spec_from_module(module, loader=None, origin=None):
# This function is meant for use in _setup().
try:
Expand Down Expand Up @@ -953,13 +950,16 @@ def _find_and_load_unlocked(name, import_):
return module


_NEEDS_LOADING = object()


def _find_and_load(name, import_):
"""Find and load the module."""
with _ModuleLockManager(name):
if name not in sys.modules:
module = sys.modules.get(name, _NEEDS_LOADING)
if module is _NEEDS_LOADING:
return _find_and_load_unlocked(name, import_)

module = sys.modules[name]
if module is None:
message = ('import of {} halted; '
'None in sys.modules'.format(name))
Expand Down
Loading