From b4645c98230700c33aaf670db99005002bc1848c Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Wed, 22 Apr 2020 13:04:03 +0300 Subject: [PATCH] Fix exception in class_sqlThread on Windows when loading database from the file with unicode character in path. Closes: #165. --- src/class_sqlThread.py | 3 ++- src/paths.py | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/class_sqlThread.py b/src/class_sqlThread.py index 84188408..2188a9cc 100644 --- a/src/class_sqlThread.py +++ b/src/class_sqlThread.py @@ -29,7 +29,8 @@ class sqlThread(threading.Thread): def run(self): # pylint: disable=too-many-locals, too-many-branches, too-many-statements """Process SQL queries from `.helper_sql.sqlSubmitQueue`""" helper_sql.sql_available = True - self.conn = sqlite3.connect(state.appdata + 'messages.dat') + self.conn = sqlite3.connect( + os.path.join(state.appdata, 'messages.dat')) self.conn.text_factory = str self.cur = self.conn.cursor() diff --git a/src/paths.py b/src/paths.py index e2f8c97e..49e312a1 100644 --- a/src/paths.py +++ b/src/paths.py @@ -23,7 +23,8 @@ def lookupExeFolder(): # targetdir/Bitmessage.app/Contents/MacOS/Bitmessage os.path.dirname(sys.executable).split(os.path.sep)[0] + os.path.sep if frozen == "macosx_app" else - os.path.dirname(sys.executable) + os.path.sep) + os.path.dirname(sys.executable).decode( + sys.getfilesystemencoding(), 'ignore') + os.path.sep) elif __file__: exeFolder = os.path.dirname(__file__) + os.path.sep else: @@ -49,11 +50,10 @@ def lookupAppdataFolder(): sys.exit( 'Could not find home folder, please report this message' ' and your OS X version to the BitMessage Github.') - elif 'win32' in sys.platform or 'win64' in sys.platform: + elif sys.platform.startswith('win'): dataFolder = os.path.join( - os.environ['APPDATA'].decode( - sys.getfilesystemencoding(), 'ignore'), APPNAME - ) + os.path.sep + os.environ['APPDATA'], APPNAME + ).decode(sys.getfilesystemencoding(), 'ignore') + os.path.sep else: try: dataFolder = os.path.join(os.environ['XDG_CONFIG_HOME'], APPNAME)