From bbc6ce8225cf54e56331ec75fa2de007d02162af Mon Sep 17 00:00:00 2001 From: Morten Enemark Lund Date: Wed, 3 Dec 2014 10:06:34 +0100 Subject: [PATCH] Fix bug where dummy_thread was always imported 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 https://github.com/ipython/ipython/pull/7079 --- src/_thread/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/_thread/__init__.py b/src/_thread/__init__.py index 63dced6e..d7a220d5 100644 --- a/src/_thread/__init__.py +++ b/src/_thread/__init__.py @@ -3,7 +3,10 @@ __future_module__ = True if sys.version_info[0] < 3: - from dummy_thread import * + try: + from thread import * + except ImportError: + from dummy_thread import * else: raise ImportError('This package should not be accessible on Python 3. ' 'Either you are trying to run from the python-future src folder '