7258: transcode os.path.join args from the fs enc to prevent a crash

This commit is contained in:
Josip 2014-04-04 22:03:51 +02:00
parent 2353c0bd34
commit 26ab379584
3 changed files with 4 additions and 4 deletions

View File

@ -515,7 +515,7 @@ def find_locker_name(dirpath):
""" """
try: try:
fname = os.path.join(dirpath, "lock") fname = os.path.join(dirpath, "lock")
ifile = io.open(fname, 'rb', encoding='utf8') ifile = io.open(fname, 'r', encoding='utf8')
username = ifile.read().strip() username = ifile.read().strip()
# feature request 2356: avoid genitive form # feature request 2356: avoid genitive form
last = _("Locked by %s") % username last = _("Locked by %s") % username

View File

@ -184,7 +184,7 @@ class RecentFiles(object):
""" """
Saves the current Gramps RecentFiles collection to the associated file. Saves the current Gramps RecentFiles collection to the associated file.
""" """
with open(os.path.expanduser(GRAMPS_FILENAME), 'w') as xml_file: with io.open(os.path.expanduser(GRAMPS_FILENAME), 'w', encoding='utf8') as xml_file:
if use_lock: if use_lock:
fcntl.lockf(xml_file,fcntl.LOCK_EX) fcntl.lockf(xml_file,fcntl.LOCK_EX)
xml_file.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n") xml_file.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
@ -222,7 +222,7 @@ class RecentParser(object):
try: try:
# Python3's expat wants bytes, Python2's wants a string. # Python3's expat wants bytes, Python2's wants a string.
fmode = "r" if sys.version_info[0] < 3 else "rb" fmode = "r" if sys.version_info[0] < 3 else "rb"
with open(fname, fmode) as xml_file: with io.open(fname, fmode) as xml_file:
if use_lock: if use_lock:
fcntl.lockf(xml_file,fcntl.LOCK_SH) fcntl.lockf(xml_file,fcntl.LOCK_SH)

View File

@ -214,7 +214,7 @@ def merge(in_file, out_file, option, po_dir='po', cache=True):
if (not os.path.exists(out_file) and os.path.exists(in_file)): if (not os.path.exists(out_file) and os.path.exists(in_file)):
if sys.platform == 'win32': if sys.platform == 'win32':
cmd = (('set LC_ALL=C && intltool-merge %(opt)s %(po_dir)s %(in_file)s ' cmd = (('set LC_ALL=C && perl -S intltool-merge %(opt)s %(po_dir)s %(in_file)s '
'%(out_file)s') % '%(out_file)s') %
{'opt' : option, {'opt' : option,
'po_dir' : po_dir, 'po_dir' : po_dir,