[Python-checkins] cpython (merge 3.3 -> default): merge for issue #17358
brett.cannon
python-checkins at python.org
Sun Apr 28 17:58:46 CEST 2013
http://hg.python.org/cpython/rev/be6bbc9f0561
changeset: 83542:be6bbc9f0561
parent: 83540:7bccf474660e
parent: 83541:3dcc81c2eef5
user: Brett Cannon <brett at python.org>
date: Sun Apr 28 11:58:31 2013 -0400
summary:
merge for issue #17358
files:
Lib/imp.py | 14 ++++++++++++--
Misc/NEWS | 3 +++
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/Lib/imp.py b/Lib/imp.py
--- a/Lib/imp.py
+++ b/Lib/imp.py
@@ -111,7 +111,12 @@
'importlib.machinery.SourceFileLoader(name, pathname).load_module()'
' instead')
warnings.warn(msg, DeprecationWarning, 2)
- return _LoadSourceCompatibility(name, pathname, file).load_module(name)
+ _LoadSourceCompatibility(name, pathname, file).load_module(name)
+ module = sys.modules[name]
+ # To allow reloading to potentially work, use a non-hacked loader which
+ # won't rely on a now-closed file object.
+ module.__loader__ = _bootstrap.SourceFileLoader(name, pathname)
+ return module
class _LoadCompiledCompatibility(_HackedGetData,
@@ -125,7 +130,12 @@
'importlib.machinery.SourcelessFileLoader(name, pathname).'
'load_module() instead ')
warnings.warn(msg, DeprecationWarning, 2)
- return _LoadCompiledCompatibility(name, pathname, file).load_module(name)
+ _LoadCompiledCompatibility(name, pathname, file).load_module(name)
+ module = sys.modules[name]
+ # To allow reloading to potentially work, use a non-hacked loader which
+ # won't rely on a now-closed file object.
+ module.__loader__ = _bootstrap.SourcelessFileLoader(name, pathname)
+ return module
def load_package(name, path):
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -52,6 +52,9 @@
Library
-------
+- Issue #17358: Modules loaded by imp.load_source() and load_compiled() (and by
+ extention load_module()) now have a better chance of working when reloaded.
+
- Issue #17804: New function ``struct.iter_unpack`` allows for streaming
struct unpacking.
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list