[Python-checkins] cpython (3.3): Issue #17098: Make sure every module has __loader__ defined.
brett.cannon
python-checkins at python.org
Fri Feb 1 20:07:44 CET 2013
http://hg.python.org/cpython/rev/05747d3bcd9c
changeset: 81869:05747d3bcd9c
branch: 3.3
parent: 81867:9d68f705e25f
user: Brett Cannon <brett at python.org>
date: Fri Feb 01 14:04:12 2013 -0500
summary:
Issue #17098: Make sure every module has __loader__ defined.
Thanks to Thomas Heller for the bug report.
files:
Lib/importlib/_bootstrap.py | 8 +-
Misc/NEWS | 3 +
Modules/signalmodule.c | 3 +-
Python/importlib.h | 572 ++++++++++++-----------
4 files changed, 298 insertions(+), 288 deletions(-)
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
--- a/Lib/importlib/_bootstrap.py
+++ b/Lib/importlib/_bootstrap.py
@@ -1703,9 +1703,11 @@
else:
BYTECODE_SUFFIXES = DEBUG_BYTECODE_SUFFIXES
- for module in (_imp, sys):
- if not hasattr(module, '__loader__'):
- module.__loader__ = BuiltinImporter
+ module_type = type(sys)
+ for module in sys.modules.values():
+ if isinstance(module, module_type):
+ if not hasattr(module, '__loader__'):
+ module.__loader__ = BuiltinImporter
self_module = sys.modules[__name__]
for builtin_name in ('_io', '_warnings', 'builtins', 'marshal'):
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,9 @@
Core and Builtins
-----------------
+- Issue #17098: All modules now have __loader__ set even if they pre-exist the
+ bootstrapping of importlib.
+
- Issue #16979: Fix error handling bugs in the unicode-escape-decode decoder.
- Issue #13886: Fix input() to not strip out input bytes that cannot be decoded
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -1367,9 +1367,8 @@
void
PyOS_InitInterrupts(void)
{
- PyObject *m = PyInit_signal();
+ PyObject *m = PyImport_ImportModule("signal");
if (m) {
- _PyImport_FixupBuiltin(m, "signal");
Py_DECREF(m);
}
}
diff --git a/Python/importlib.h b/Python/importlib.h
--- a/Python/importlib.h
+++ b/Python/importlib.h
[stripped]
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list