Correctly encode the contents of the lock file.
This commit is contained in:
parent
4299ef530e
commit
9550dda584
@ -45,6 +45,7 @@ else:
|
||||
from urllib.parse import urlparse
|
||||
from urllib.request import urlopen, url2pathname
|
||||
import tempfile
|
||||
import io
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# set up logging
|
||||
@ -219,9 +220,6 @@ 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[_("Path")] = dirpath
|
||||
retval[_("Last accessed")] = time.strftime('%x %X',
|
||||
@ -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()
|
||||
|
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user