From 9550dda584a9632cace4020d6160af370ee09799 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Tue, 1 Apr 2014 17:37:32 -0700 Subject: [PATCH] Correctly encode the contents of the lock file. --- gramps/cli/clidbman.py | 12 +++--------- gramps/gen/db/write.py | 3 ++- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/gramps/cli/clidbman.py b/gramps/cli/clidbman.py index 2ec6b1145..466849ff6 100644 --- a/gramps/cli/clidbman.py +++ b/gramps/cli/clidbman.py @@ -45,6 +45,7 @@ else: from urllib.parse import urlparse from urllib.request import urlopen, url2pathname import tempfile +import io #------------------------------------------------------------------------- # # set up logging @@ -219,10 +220,7 @@ class CLIDbManager(object): retval[_("Locked?")] = _("no") retval[_("Bsddb version")] = bsddb_version retval[_("Schema version")] = schema_version - if sys.version_info[0] < 3: - retval[_("Family Tree")] = name.encode(glocale.getfilesystemencoding()) - else: - retval[_("Family Tree")] = name + retval[_("Family Tree")] = name retval[_("Path")] = dirpath retval[_("Last accessed")] = time.strftime('%x %X', time.localtime(tval)) @@ -517,12 +515,8 @@ def find_locker_name(dirpath): """ try: fname = os.path.join(dirpath, "lock") - ifile = open(fname, 'rb') + ifile = io.open(fname, 'rb', encoding='utf8') username = ifile.read().strip() - # Convert username to unicode according to system encoding - # Otherwise problems with non ASCII characters in - # username in Windows - username = conv_to_unicode(username, glocale.getfilesystemencoding()) # feature request 2356: avoid genitive form last = _("Locked by %s") % username ifile.close() diff --git a/gramps/gen/db/write.py b/gramps/gen/db/write.py index 70eb2fcda..019aa125e 100644 --- a/gramps/gen/db/write.py +++ b/gramps/gen/db/write.py @@ -41,6 +41,7 @@ else: import os import time import bisect +import io from functools import wraps import logging from sys import maxsize, getfilesystemencoding, version_info @@ -2464,7 +2465,7 @@ def clear_lock_file(name): def write_lock_file(name): if not os.path.isdir(name): os.mkdir(name) - f = open(os.path.join(name, DBLOCKFN), "w") + f = io.open(os.path.join(name, DBLOCKFN), "w", encoding='utf8') if win(): user = get_env_var('USERNAME') host = get_env_var('USERDOMAIN')