From e8b79c6bff9f527713919d32478b73dd8a9e30d9 Mon Sep 17 00:00:00 2001 From: Ilias Tsitsimpis Date: Thu, 6 Oct 2016 13:30:48 +0300 Subject: [PATCH] Import ui before threadutil to resolve circular dependency The `threadutil` module depends on the `ui` module, which cycle depends on `threadutil` through the `Curses` module. The `ui` module had been loaded before the `threadutil` module, breaking the above circular dependency, but this was changed in a recent code refactoring, preventing the `Curses` module from being loaded with the following exception: File "./offlineimap.py", line 23, in from offlineimap import OfflineImap File "offlineimap/offlineimap/__init__.py", line 20, in from offlineimap.init import OfflineImap File "offlineimap/offlineimap/init.py", line 30, in from offlineimap import globals, threadutil, accounts, folder, mbnames File "offlineimap/offlineimap/threadutil.py", line 25, in from offlineimap.ui import getglobalui File "offlineimap/offlineimap/ui/__init__.py", line 28, in from offlineimap.ui import Curses File "offlineimap/offlineimap/ui/Curses.py", line 27, in from offlineimap.threadutil import ExitNotifyThread ImportError: cannot import name ExitNotifyThread Fix the above error by ensuring that the `ui` module gets loaded before the `threadutil` module. Please note that the above fix is temporary, and we should refactor the modules to not have circular dependencies. Bug-Debian: https://bugs.debian.org/839862 Reported-by: Neil McGovern Signed-off-by: Ilias Tsitsimpis Signed-off-by: Nicolas Sebrecht --- offlineimap/init.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/offlineimap/init.py b/offlineimap/init.py index 51ad544..efa438a 100644 --- a/offlineimap/init.py +++ b/offlineimap/init.py @@ -27,8 +27,11 @@ from optparse import OptionParser import offlineimap import offlineimap.virtual_imaplib2 as imaplib -from offlineimap import globals, threadutil, accounts, folder, mbnames + +# Ensure that `ui` gets loaded before `threadutil` in order to +# break the circular dependency between `threadutil` and `Curses`. from offlineimap.ui import UI_LIST, setglobalui, getglobalui +from offlineimap import globals, threadutil, accounts, folder, mbnames from offlineimap.CustomConfig import CustomConfigParser from offlineimap.utils import stacktrace from offlineimap.repository import Repository