Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deepreload fails on Python 3 #1622

Closed
takluyver opened this issue Apr 18, 2012 · 1 comment · Fixed by #1625
Closed

deepreload fails on Python 3 #1622

takluyver opened this issue Apr 18, 2012 · 1 comment · Fixed by #1625
Labels
Milestone

Comments

@takluyver
Copy link
Member

Verbose traceback (including variables) is available here: https://gist.github.com/2413637

It looks like there's a couple of issues. First, imp.find_module('B') seems to be trying to import other modules, because the next visible stack frame is the __import__ hook being called for the io module. We may have to replace the original __import__ hook while we call that.

Secondly, it seems to hit a bump with the sys.modules modification in os. os imports path from elsewhere, and adds it to sys.modules as 'os.path'.

@takluyver
Copy link
Member Author

Also, looking at the signature of IPython.lib.deepreload.reload, you can pass a list of modules to exclude, but doing so wipes out the default list of exclusions (including os.path). There should probably be a way to add to the exclude list without having to re-enter the default exclusions.

fperez added a commit that referenced this issue Apr 18, 2012
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.
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
Fix deepreload on Python 3.

As described in ipython#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 ipythongh-1622.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant