Skip to content

Commit e15d4ed

Browse files
committed
Fix exception in class_sqlThread on Windows
when loading database from the file with unicode character in path.
1 parent ff1f451 commit e15d4ed

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/class_sqlThread.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ def __init__(self):
2828

2929
def run(self): # pylint: disable=too-many-locals, too-many-branches, too-many-statements
3030
"""Process SQL queries from `.helper_sql.sqlSubmitQueue`"""
31-
self.conn = sqlite3.connect(state.appdata + 'messages.dat')
31+
self.conn = sqlite3.connect(
32+
os.path.join(state.appdata, 'messages.dat'))
3233
self.conn.text_factory = str
3334
self.cur = self.conn.cursor()
3435

src/paths.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ def lookupExeFolder():
2323
# targetdir/Bitmessage.app/Contents/MacOS/Bitmessage
2424
os.path.dirname(sys.executable).split(os.path.sep)[0] + os.path.sep
2525
if frozen == "macosx_app" else
26-
os.path.dirname(sys.executable) + os.path.sep)
26+
os.path.dirname(sys.executable).decode(
27+
sys.getfilesystemencoding(), 'ignore') + os.path.sep)
2728
elif __file__:
2829
exeFolder = os.path.dirname(__file__) + os.path.sep
2930
else:
@@ -49,11 +50,10 @@ def lookupAppdataFolder():
4950
sys.exit(
5051
'Could not find home folder, please report this message'
5152
' and your OS X version to the BitMessage Github.')
52-
elif 'win32' in sys.platform or 'win64' in sys.platform:
53+
elif sys.platform.startswith('win'):
5354
dataFolder = os.path.join(
54-
os.environ['APPDATA'].decode(
55-
sys.getfilesystemencoding(), 'ignore'), APPNAME
56-
) + os.path.sep
55+
os.environ['APPDATA'], APPNAME
56+
).decode(sys.getfilesystemencoding(), 'ignore') + os.path.sep
5757
else:
5858
try:
5959
dataFolder = os.path.join(os.environ['XDG_CONFIG_HOME'], APPNAME)

0 commit comments

Comments
 (0)