[issue14609] can't modify sys.modules during import with importlib

2012-04-18 Thread Benjamin Peterson
Changes by Benjamin Peterson : -- resolution: -> fixed status: open -> closed ___ Python tracker ___ ___ Python-bugs-list mailing lis

[issue14609] can't modify sys.modules during import with importlib

2012-04-18 Thread Roundup Robot
Roundup Robot added the comment: New changeset db5e3431ee4c by Benjamin Peterson in branch 'default': rollback 005fd1fe31ab (see #14609 and #14582) http://hg.python.org/cpython/rev/db5e3431ee4c -- nosy: +python-dev ___ Python tracker

[issue14609] can't modify sys.modules during import with importlib

2012-04-18 Thread Eric Snow
Eric Snow added the comment: > I would advocate breaking any compatability. Did you mean "against breaking any compatability"? The problem is that it's just one more sticky little detail that adds to the complexity of understanding the import system. It's things like this that turn people o

[issue14609] can't modify sys.modules during import with importlib

2012-04-18 Thread Benjamin Peterson
Benjamin Peterson added the comment: I would advocate breaking any compatability. In fact, I think it can be documented. This is a useful feature, and not hard to maintain. -- ___ Python tracker _

[issue14609] can't modify sys.modules during import with importlib

2012-04-18 Thread Brett Cannon
Brett Cannon added the comment: I honestly don't care enough to argue over this one (I was trying to save a dict lookup but unfortunately too many people have codified the behaviour already). Just revert http://hg.python.org/cpython/rev/005fd1fe31ab to get back the original behaviour. --

[issue14609] can't modify sys.modules during import with importlib

2012-04-18 Thread Eric Snow
Eric Snow added the comment: that's a pretty sneaky hack, but I can see the (weak) point of it. So, to keep backward compatibility, importlib._bootstrap._find_and_load() would have to return sys.modules[fullname] instead of the module returned by loader.load_module(fullname). My inclination

[issue14609] can't modify sys.modules during import with importlib

2012-04-18 Thread Benjamin Peterson
Benjamin Peterson added the comment: This is a really important usecase for many packages including py.test and twisted, though. -- ___ Python tracker ___ _

[issue14609] can't modify sys.modules during import with importlib

2012-04-17 Thread Eric Snow
Eric Snow added the comment: _find_and_load() in importlib._bootstrap returns whatever the loader returns, which is the new module object. The old code in import.c pulled it from sys.modules rather than using what the loader returned. In both cases the respective object is what eventually g

[issue14609] can't modify sys.modules during import with importlib

2012-04-17 Thread Eric Snow
Eric Snow added the comment: 3.3.0a2+: >>> import x >>> x >>> import sys >>> sys.modules['x'] 5 >>> x 5 -- ___ Python tracker ___ _

[issue14609] can't modify sys.modules during import with importlib

2012-04-17 Thread Eric Snow
Eric Snow added the comment: Loaders are in charge of adding the module to sys.modules (per PEP 302). importlib codifies this in the module_for_loader() decorator, which the default loaders use. -- nosy: +eric.snow ___ Python tracker

[issue14609] can't modify sys.modules during import with importlib

2012-04-17 Thread Philip Jenvey
Philip Jenvey added the comment: __import__ needs the actual module on hand so it can e.g. attach it to its parent module -- nosy: +pjenvey ___ Python tracker ___ _

[issue14609] can't modify sys.modules during import with importlib

2012-04-17 Thread Benjamin Peterson
New submission from Benjamin Peterson : $ cat > x.py import sys sys.modules["x"] = 42 benjamin@localhost ~/dev/python/py3k $ python3 Python 3.2.2 (default, Feb 18 2012, 09:16:28) [GCC 4.5.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import x >>> x 42