win32_py3: open use system encoding
svn: r21338
This commit is contained in:
parent
866796f5dc
commit
db1bd1e114
@ -46,7 +46,7 @@ from ..const import VERSION as GRAMPSVERSION, VERSION_TUPLE
|
||||
from ..const import IMAGE_DIR
|
||||
from ..utils.trans import get_addon_translator
|
||||
from ..ggettext import gettext as _
|
||||
from ..constfunc import STRTYPE
|
||||
from ..constfunc import STRTYPE, win
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -1093,10 +1093,14 @@ class PluginRegister(object):
|
||||
full_filename = full_filename.encode(sys.getfilesystemencoding())
|
||||
local_gettext = get_addon_translator(full_filename).gettext
|
||||
try:
|
||||
#execfile(full_filename,
|
||||
exec(compile(open(full_filename).read(), full_filename, 'exec'),
|
||||
make_environment(_=local_gettext),
|
||||
{})
|
||||
if win() and not sys.version_info[0] < 3:
|
||||
exec(compile(open(full_filename, encoding='utf-8').read(),
|
||||
full_filename, 'exec'), make_environment(_=local_gettext),
|
||||
{})
|
||||
else:
|
||||
#execfile(full_filename,
|
||||
exec(compile(open(full_filename).read(), full_filename,
|
||||
'exec'), make_environment(_=local_gettext), {})
|
||||
except ValueError as msg:
|
||||
print(_('ERROR: Failed reading plugin registration %(filename)s') % \
|
||||
{'filename' : filename})
|
||||
|
@ -43,7 +43,7 @@ import errno
|
||||
import copy
|
||||
import logging
|
||||
|
||||
from ..constfunc import STRTYPE
|
||||
from ..constfunc import STRTYPE, win
|
||||
|
||||
def safe_eval(exp):
|
||||
# restrict eval to empty environment
|
||||
@ -255,7 +255,10 @@ class ConfigManager(object):
|
||||
if filename and os.path.exists(filename):
|
||||
parser = configparser.RawConfigParser()
|
||||
try: # see bugs 5356, 5490, 5591, 5651, 5718, etc.
|
||||
parser.read(filename)
|
||||
if win() and not sys.version_info[0] < 3:
|
||||
parser.read(filename, encoding='utf8')
|
||||
else:
|
||||
parser.read(filename)
|
||||
except:
|
||||
msg1 = _("WARNING: could not parse file, recreating it:\n%s")
|
||||
print(msg1 % filename, file=sys.stderr)
|
||||
@ -334,7 +337,10 @@ class ConfigManager(object):
|
||||
except OSError as exp:
|
||||
if exp.errno != errno.EEXIST:
|
||||
raise
|
||||
key_file = open(filename, "w")
|
||||
if win() and not sys.version_info[0] < 3:
|
||||
key_file = open(filename, "w", encoding='utf-8')
|
||||
else:
|
||||
key_file = open(filename, "w")
|
||||
key_file.write(";; Gramps key file\n")
|
||||
key_file.write((";; Automatically created at %s" %
|
||||
time.strftime("%Y/%m/%d %H:%M:%S")) + "\n\n")
|
||||
|
@ -55,6 +55,7 @@ from gi.repository import Gtk
|
||||
#-------------------------------------------------------------------------
|
||||
from gramps.gen.const import URL_MANUAL_PAGE, VERSION_DIR
|
||||
from gramps.gen.config import config
|
||||
from gramps.gen.constfunc import win
|
||||
from ..managedwindow import ManagedWindow
|
||||
from ..display import display_help, display_url
|
||||
from .grampletpane import (AVAILABLE_GRAMPLETS,
|
||||
@ -190,7 +191,10 @@ class GrampletBar(Gtk.Notebook):
|
||||
"""
|
||||
filename = self.configfile
|
||||
try:
|
||||
fp = open(filename, "w")
|
||||
if win() and not sys.version_info[0] < 3:
|
||||
fp = open(filename, "w", encoding='utf-8')
|
||||
else:
|
||||
fp = open(filename, "w")
|
||||
except IOError:
|
||||
print("Failed writing '%s'; gramplets not saved" % filename)
|
||||
return
|
||||
|
@ -39,6 +39,7 @@ from gi.repository import Pango
|
||||
import time
|
||||
import os
|
||||
from gramps.gen.ggettext import gettext as _
|
||||
from gramps.gen.constfunc import win
|
||||
import sys
|
||||
if sys.version_info[0] < 3:
|
||||
import ConfigParser as configparser
|
||||
@ -1168,7 +1169,10 @@ class GrampletPane(Gtk.ScrolledWindow):
|
||||
return # something is the matter
|
||||
filename = self.configfile
|
||||
try:
|
||||
fp = open(filename, "w")
|
||||
if win() and not sys.version_info[0] < 3:
|
||||
fp = open(filename, "w", encoding='utf-8')
|
||||
else:
|
||||
fp = open(filename, "w")
|
||||
except IOError:
|
||||
print("Failed writing '%s'; gramplets not saved" % filename)
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user