mirror of
https://github.com/python/cpython.git
synced 2025-08-27 04:05:34 +00:00
Issue #12599: Be more strict in accepting None vs. a false-like object
in importlib. Thanks to PJE for pointing out the issue and Nick Coghlan for filing the bug.
This commit is contained in:
parent
64befe939c
commit
7bd329d800
5 changed files with 1240 additions and 1212 deletions
|
@ -217,7 +217,7 @@ def module_for_loader(fxn):
|
|||
"""
|
||||
def module_for_loader_wrapper(self, fullname, *args, **kwargs):
|
||||
module = sys.modules.get(fullname)
|
||||
is_reload = bool(module)
|
||||
is_reload = module is not None
|
||||
if not is_reload:
|
||||
# This must be done before open() is called as the 'io' module
|
||||
# implicitly imports 'locale' and would otherwise trigger an
|
||||
|
@ -711,7 +711,7 @@ class PathFinder:
|
|||
If 'hooks' is false then use sys.path_hooks.
|
||||
|
||||
"""
|
||||
if not hooks:
|
||||
if hooks is None:
|
||||
hooks = sys.path_hooks
|
||||
for hook in hooks:
|
||||
try:
|
||||
|
@ -753,7 +753,7 @@ class PathFinder:
|
|||
def find_module(cls, fullname, path=None):
|
||||
"""Find the module on sys.path or 'path' based on sys.path_hooks and
|
||||
sys.path_importer_cache."""
|
||||
if not path:
|
||||
if path is None:
|
||||
path = sys.path
|
||||
for entry in path:
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue