This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: change importlib.util.module_for_loader to unconditionally set attributes
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: brett.cannon Nosy List: barry, brett.cannon, eric.smith, eric.snow, ncoghlan, python-dev
Priority: normal Keywords:

Created on 2013-05-27 13:59 by brett.cannon, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg190139 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2013-05-27 13:59
importlib.util.module_for_loader (as well as set_package and set_loader) only set those attributes either when they are not already set or when the module is new. I realized this is a problem as it means a reload won't work the way one might expect.

I want to at least change module_for_loader since I suspect that is in wider use, but probably all three decorators to unconditionally set their respective attributes so reloads operate as expected. Unfortunately that is backwards-incompatible, albeit for probably a rare case if anyone actually cares.

Anyone see a reason why doing this is a bad idea and it shouldn't be done?
msg190141 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2013-05-27 14:38
I don't think anyone would (or should!) write code that cares, so I think your proposed change is a good one.
msg190253 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-05-28 22:36
New changeset 185a0e649fb8 by Brett Cannon in branch 'default':
Issue #18070: importlib.util.module_for_loader() now sets __loader__
http://hg.python.org/cpython/rev/185a0e649fb8
History
Date User Action Args
2022-04-11 14:57:46adminsetgithub: 62270
2013-05-28 22:43:11brett.cannonsetstatus: open -> closed
resolution: fixed
stage: test needed -> resolved
2013-05-28 22:36:05python-devsetnosy: + python-dev
messages: + msg190253
2013-05-27 15:07:51brett.cannonsetassignee: brett.cannon
2013-05-27 14:38:12eric.smithsetmessages: + msg190141
2013-05-27 13:59:43brett.cannoncreate