[Python-checkins] cpython: Issue #21052: Don't raise ImportWarning for sys.meta_path or
brett.cannon
python-checkins at python.org
Fri Oct 10 16:54:51 CEST 2014
https://hg.python.org/cpython/rev/d9f71bc6d897
changeset: 92927:d9f71bc6d897
user: Brett Cannon <brett at python.org>
date: Fri Oct 10 10:54:28 2014 -0400
summary:
Issue #21052: Don't raise ImportWarning for sys.meta_path or
sys.path_hooks when set to None during interpreter shutdown.
Thanks to Martin Panter for the initial bug report.
files:
Lib/importlib/_bootstrap.py | 4 +-
Misc/NEWS | 3 +
Python/importlib.h | 50 +++++++++++++------------
3 files changed, 31 insertions(+), 26 deletions(-)
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -1806,7 +1806,7 @@
If 'hooks' is false then use sys.path_hooks.
"""
- if not sys.path_hooks:
+ if sys.path_hooks is not None and not sys.path_hooks:
_warnings.warn('sys.path_hooks is empty', ImportWarning)
for hook in sys.path_hooks:
try:
@@ -2095,7 +2095,7 @@
def _find_spec(name, path, target=None):
"""Find a module's loader."""
- if not sys.meta_path:
+ if sys.meta_path is not None and not sys.meta_path:
_warnings.warn('sys.meta_path is empty', ImportWarning)
# We check sys.modules here for the reload case. While a passed-in
# target will usually indicate a reload there is no guarantee, whereas
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
Core and Builtins
-----------------
+- Issue #21052: Do not raise ImportWarning when sys.path_hooks or sys.meta_path
+ are set to None.
+
- Issue #16518: Use 'bytes-like object required' in error messages that
previously used the far more cryptic "'x' does not support the buffer
protocol.
diff --git a/Python/importlib.h b/Python/importlib.h
--- a/Python/importlib.h
+++ b/Python/importlib.h
[stripped]
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list