[issue37521] importlib examples have their exec_module()/sys.modules assignment lines reversed

2019-07-17 Thread Brett Cannon
Brett Cannon added the comment: If you're using your example code for 'testext' that you uploaded then that's expected because the import in your package causes a normal import which means the import machinery is adding things to sys.modules. Try it with a plain module that's empty so you

[issue37521] importlib examples have their exec_module()/sys.modules assignment lines reversed

2019-07-17 Thread Benjamin Mintz
Benjamin Mintz added the comment: ``` name = 'testext' spec = importlib.util.find_spec(name) print(name in sys.modules) module = importlib.util.module_from_spec(spec) print(name in sys.modules) spec.loader.exec_module(module) print(name in sys.modules) ``` This prints False, False, True

[issue37521] importlib examples have their exec_module()/sys.modules assignment lines reversed

2019-07-16 Thread Brett Cannon
Brett Cannon added the comment: Nope, loader.exec_module() doesn't either: https://docs.python.org/3/library/importlib.html#importlib.abc.Loader.exec_module, https://github.com/python/cpython/blob/master/Lib/importlib/_bootstrap_external.py#L776. So unfortunately I'm still not sure what

[issue37521] importlib examples have their exec_module()/sys.modules assignment lines reversed

2019-07-16 Thread Benjamin Mintz
Benjamin Mintz added the comment: I dunno, one of those three does. I suppose it's spec.loader.exec_module(). -- ___ Python tracker ___

[issue37521] importlib examples have their exec_module()/sys.modules assignment lines reversed

2019-07-15 Thread Brett Cannon
Brett Cannon added the comment: I'm not sure why you think importlib.util.module_from_spec() adds a module to sys.modules? https://docs.python.org/3/library/importlib.html#importlib.util.module_from_spec doesn't say that nor does

[issue37521] importlib examples have their exec_module()/sys.modules assignment lines reversed

2019-07-13 Thread Benjamin Mintz
Benjamin Mintz added the comment: Hmm, why is the assignment to sys.modules necessary at all, if module_from_spec() always does so? -- ___ Python tracker ___

[issue37521] importlib examples have their exec_module()/sys.modules assignment lines reversed

2019-07-12 Thread Brett Cannon
Brett Cannon added the comment: Thanks for the report, Benjamin! -- resolution: -> fixed stage: patch review -> needs patch status: open -> closed ___ Python tracker ___

[issue37521] importlib examples have their exec_module()/sys.modules assignment lines reversed

2019-07-12 Thread miss-islington
miss-islington added the comment: New changeset bfb709b771230e7e466961b5ddf4852962602450 by Miss Islington (bot) in branch '3.8': [3.8] bpo-37521: No longer treat insertion into sys.modules as optional in importlib examples (GH-14723) (GH-14724)

[issue37521] importlib examples have their exec_module()/sys.modules assignment lines reversed

2019-07-12 Thread miss-islington
Change by miss-islington : -- pull_requests: +14520 pull_request: https://github.com/python/cpython/pull/14724 ___ Python tracker ___

[issue37521] importlib examples have their exec_module()/sys.modules assignment lines reversed

2019-07-12 Thread miss-islington
miss-islington added the comment: New changeset 0827064c955f88df8ba5621d8e3d81be3cfc26a9 by Miss Islington (bot) (Brett Cannon) in branch 'master': bpo-37521: No longer treat insertion into sys.modules as optional in importlib examples (GH-14723)

[issue37521] importlib examples have their exec_module()/sys.modules assignment lines reversed

2019-07-12 Thread Brett Cannon
Change by Brett Cannon : -- keywords: +patch pull_requests: +14519 stage: needs patch -> patch review pull_request: https://github.com/python/cpython/pull/14723 ___ Python tracker

[issue37521] importlib examples have their exec_module()/sys.modules assignment lines reversed

2019-07-12 Thread Brett Cannon
Brett Cannon added the comment: I will have a PR up shortly to fix the docs. -- ___ Python tracker ___ ___ Python-bugs-list

[issue37521] importlib examples have their exec_module()/sys.modules assignment lines reversed

2019-07-12 Thread Brett Cannon
Brett Cannon added the comment: So the issue is the lines assigning to sys.modules and loader.exec_module() are reversed. Had you not done an import in your testext.__init__ you never would have noticed, but since you are then the normal import system is noticing there's nothing in