classification
Title: importlib.reload() does not return the module in sys.modules
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.4, Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: eric.snow Nosy List: brett.cannon, eric.snow, python-dev
Priority: normal Keywords: patch

Created on 2013-08-09 23:27 by eric.snow, last changed 2013-08-15 00:23 by eric.snow. This issue is now closed.

Files
File name Uploaded Description Edit
reload_replaced_module.diff eric.snow, 2013-08-14 06:34
Messages (6)
msg194776 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2013-08-09 23:27
Currently reload() returns the module that loader.load_module() returns, rather than returning the one in sys.modules.  This is different from what happens during normal import.  I would expect reload() to return what's in sys.modules.  Perhaps this got overlooked when we moved reload()?  I haven't had a chance to verify, but I do recall that the switch to importlib-based import in 3.3 exposed a bug where importlib wasn't returning the module in sys.modules during normal import.
msg194827 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2013-08-10 20:01
I'm sure it's an oversight.
msg195125 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2013-08-14 06:34
Yep.  In 2.7 and 3.2 the PyImport_ExecCodeModuleEx() function in Python/importlib.c returns the module found in sys.modules.  Here is a patch.  I suppose this should be fixed in 2.7 as well.  Thoughts?
msg195177 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2013-08-14 15:11
I think you mean in 3.3 and yes. =) Patch LGTM so I say fix in 3.3 and merge into default.
msg195229 - (view) Author: Roundup Robot (python-dev) Date: 2013-08-15 00:18
New changeset e22e7268e58a by Eric Snow in branch '3.3':
issue #18698: ensure importlib.reload() returns the module out of sys.modules.
http://hg.python.org/cpython/rev/e22e7268e58a

New changeset 1af087712e69 by Eric Snow in branch 'default':
Closes issue #18698: ensure importlib.reload() returns the module out of sys.modules.
http://hg.python.org/cpython/rev/1af087712e69
msg195230 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2013-08-15 00:23
oops.  That commit message for 3.3 should have read "imp.reload()". :)
History
Date User Action Args
2013-08-15 00:23:16eric.snowsetstatus: open -> closed
resolution: fixed
messages: + msg195230

stage: patch review -> resolved
2013-08-15 00:18:33python-devsetnosy: + python-dev
messages: + msg195229
2013-08-14 15:11:04brett.cannonsetassignee: eric.snow
messages: + msg195177
2013-08-14 06:34:20eric.snowsetfiles: + reload_replaced_module.diff
keywords: + patch
messages: + msg195125

stage: patch review
2013-08-10 20:01:14brett.cannonsetmessages: + msg194827
2013-08-09 23:27:18eric.snowcreate