Skip to content

Fix incompatibility with the python-future package - #7079

Closed
melund wants to merge 1 commit into
ipython:masterfrom
melund:master
Closed

melund wants to merge 1 commit into
ipython:masterfrom
melund:master

Conversation

@melund

@melund melund commented Dec 2, 2014

Copy link
Copy Markdown

The python-future ( http://python-future.org/ ) package provides a dummy version the _thread module for python2. This causes the dummy library to be loaded instead. The effect is that for example the 'Interrupt' button in ipython notebook doesn't work.

This fix ensures that we try to import the python 2 code first, thus preventing the _thread module from being imported when the future package is installed.

The python-future ( http://python-future.org/ )  package provides a dummy version the _thread module for python2. This causes the dummy library to be loaded instead. The effect is that for example the 'Interrupt' button in ipython notebook doesn't work.

This fix ensures that we try to import the python 2 code first, thus preventing the _thread module from being imported when the future package is installed.
@minrk

minrk commented Dec 2, 2014

Copy link
Copy Markdown
Member

Oof, that seems like a pretty bad bug in python-future.

@rgbkrk

rgbkrk commented Dec 3, 2014

Copy link
Copy Markdown
Member

The annoying part about a fix like this is that it's completely non-obvious what it's "fixing". If another dev decides to switch the conditional around, they should "be the same right"?

@takluyver

Copy link
Copy Markdown
Member

Hang on, why is that breaking things? python-future is there for compatibility; shouldn't its _thread module expose the same function from the Python 2 thread module? Why is there a problem?

@takluyver

Copy link
Copy Markdown
Member

Yeah, I think that's a plain and simple bug: the _thread module in python-future is importing dummy_thread, when it should be importing thread.

https://github.com/PythonCharmers/python-future/blob/master/src/_thread/__init__.py

Closing as not our bug. If other packages install standard library shims, it's up to them to get that right.

@takluyver takluyver closed this Dec 3, 2014
melund added a commit to melund/python-future that referenced this pull request Dec 3, 2014
The code always import the dummy_thread module even on platforms where the real thread module is available. This caused bugs in other packages that use this import style:

try:
    from _thread import interrupt_main  # Py 3
except ImportError:
    from thread import interrupt_main  # Py 2

See  ipython/ipython#7079
@melund

melund commented Dec 3, 2014

Copy link
Copy Markdown
Author

I agree that this is not your bug. It is kind of annoying thus, as python-future is included by default in the anaconda python distribution.

I have created a pull request for the python-future package
PythonCharmers/python-future#124

Enlighten me, would it not be a better practice to actually check the python version when importing instead of assuming that _thread is not availble on python2.

@edschofield

Copy link
Copy Markdown

This bug is now fixed in python-future v0.14.3.

@takluyver

Copy link
Copy Markdown
Member

Thanks @edschofield

@minrk minrk added this to the no action milestone Dec 14, 2014
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.

6 participants