merge for issue #17358

This commit is contained in:
Brett Cannon 2013-04-28 11:58:31 -04:00
commit e1d30f24ee
2 changed files with 15 additions and 2 deletions

View File

@ -111,7 +111,12 @@ def load_source(name, pathname, file=None):
'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 @@ def load_compiled(name, pathname, file=None):
'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):

View File

@ -52,6 +52,9 @@ Core and Builtins
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.