Skip to content

Remove importlib dependency which not available in Python 2.6.#1882

Merged
fperez merged 1 commit into
ipython:masterfrom
bfroehle:_1874_import_module
Jun 8, 2012
Merged

Remove importlib dependency which not available in Python 2.6.#1882
fperez merged 1 commit into
ipython:masterfrom
bfroehle:_1874_import_module

Conversation

@bfroehle
Copy link
Copy Markdown
Contributor

@bfroehle bfroehle commented Jun 8, 2012

Since we are only doing an absolute import, it suffices to just run
__import__(name) and then find the module in sys.modules.

Compare to the import_module source:

def import_module(name, package=None):
    if name.startswith('.'):
        # ...
    __import__(name)
    return sys.modules[name]

Closes #1874.

Since we are only doing an absolute import, it suffices to just run
`__import__(name)` and then find the module in `sys.modules`.

Closes ipython#1874.
@ivanov
Copy link
Copy Markdown
Member

ivanov commented Jun 8, 2012

Thanks, Brad. This fix looks clean if we don't expect relative imports to be made here, since that's what the omitted if name.startswith('.'): block does.

@bfroehle
Copy link
Copy Markdown
Contributor Author

bfroehle commented Jun 8, 2012

Yep, and we certainly wouldn't be using relative imports here.

@fperez
Copy link
Copy Markdown
Member

fperez commented Jun 8, 2012

Test results for commit 7067c17 merged into master
Platform: linux2

  • python2.7: Failed, log at https://gist.github.com/2893394 (libraries not available: wx.aui)
  • python3.2: OK (libraries not available: cython matplotlib pymongo rpy2 wx wx.aui)

Not available for testing:

@fperez
Copy link
Copy Markdown
Member

fperez commented Jun 8, 2012

Mmh, I'm getting that failure above, but I'm also seeing problems on master right now. How about you guys? This PR actually looks clean, but I'd prefer to get master back in passing shape before doing any more merging...

@fperez
Copy link
Copy Markdown
Member

fperez commented Jun 8, 2012

Actually, this is really too simple to block on, let's go ahead. Thanks @bfroehle! My worry on master remains, but that's a separate problem.

fperez added a commit that referenced this pull request Jun 8, 2012
Remove importlib dependency which not available in Python 2.6.

Since we are only doing an absolute import, it suffices to just run
__import__(name) and then find the module in sys.modules.

Closes #1874.
@fperez fperez merged commit 7a50de9 into ipython:master Jun 8, 2012
@ivanov
Copy link
Copy Markdown
Member

ivanov commented Jun 8, 2012

@fperez: i'm seeing that same error, fwiw

@fperez
Copy link
Copy Markdown
Member

fperez commented Jun 8, 2012

On Thu, Jun 7, 2012 at 9:59 PM, Paul Ivanov
reply@reply.github.com
wrote:

@fperez: i'm seeing that same error, fwiw

Mmh, ok... We'll have to get master in shape soon then, thanks!

f

mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
Remove importlib dependency which not available in Python 2.6.

Since we are only doing an absolute import, it suffices to just run
__import__(name) and then find the module in sys.modules.

Closes ipython#1874.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cython_magic uses importlib, which doesn't ship with py2.6

3 participants