Fix deepreload on Python 3 #1625

Merged
merged 1 commit into from Apr 18, 2012

Conversation

Projects
None yet
2 participants
@takluyver
Member

takluyver commented Apr 18, 2012

As described in #1622, it seems that imp.find_module() on Python 3.2 imports other modules, like io, while running. We don't want deepreload to catch those, so this restores the original import hook for find_module.

It's not terribly neat, but I don't currently see a better way of doing it. Ideally, we'd just delay installing our __import__ until after find_module had run, but our implementation of __import__ can itself call find_module, so this little dance seems to be necessary.

Closes gh-1622, and hopefully fixes a test failure we saw last night.

@fperez

This comment has been minimized.

Show comment
Hide comment
@fperez

fperez Apr 18, 2012

Member

Great, thanks! Looks clean, merging now. And yet again, the Panda shines and caught this! I'm really happy that you set that up, we're reaping the benefits every day.

Member

fperez commented Apr 18, 2012

Great, thanks! Looks clean, merging now. And yet again, the Panda shines and caught this! I'm really happy that you set that up, we're reaping the benefits every day.

fperez added a commit that referenced this pull request Apr 18, 2012

Merge pull request #1625 from takluyver/i1622
Fix deepreload on Python 3.

As described in #1622, it seems that `imp.find_module()` on Python 3.2 imports other modules, like `io`, while running. We don't want deepreload to catch those, so this restores the original import hook for `find_module`.

It's not terribly neat, but I don't currently see a better way of doing it. Ideally, we'd just delay installing our `__import__` until after `find_module` had run, but our implementation of `__import__` can itself call `find_module`, so this little dance seems to be necessary.

Closes gh-1622.

@fperez fperez merged commit 0eb2ae9 into ipython:master Apr 18, 2012

mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014

Merge pull request #1625 from takluyver/i1622
Fix deepreload on Python 3.

As described in #1622, it seems that `imp.find_module()` on Python 3.2 imports other modules, like `io`, while running. We don't want deepreload to catch those, so this restores the original import hook for `find_module`.

It's not terribly neat, but I don't currently see a better way of doing it. Ideally, we'd just delay installing our `__import__` until after `find_module` had run, but our implementation of `__import__` can itself call `find_module`, so this little dance seems to be necessary.

Closes gh-1622.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment