From efa3741579ecabee2f6807ab69a5981ce35158d3 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Sun, 20 Apr 2014 13:48:59 -0700 Subject: [PATCH] 7258: Ensure that resource paths are set correctly when they include Unicode characters. --- gramps/gen/utils/resourcepath.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gramps/gen/utils/resourcepath.py b/gramps/gen/utils/resourcepath.py index 414edaf60..3f1bb873e 100644 --- a/gramps/gen/utils/resourcepath.py +++ b/gramps/gen/utils/resourcepath.py @@ -17,7 +17,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # - +from __future__ import unicode_literals import sys import io import os @@ -27,7 +27,7 @@ _hdlr = logging.StreamHandler() _hdlr.setFormatter(logging.Formatter(fmt="%(name)s.%(levelname)s: %(message)s")) LOG.addHandler(_hdlr) -from ..constfunc import get_env_var +from ..constfunc import get_env_var, conv_to_unicode class ResourcePath(object): """ @@ -50,8 +50,8 @@ class ResourcePath(object): if self.initialized: return - resource_file = os.path.join(os.path.abspath(os.path.dirname(__file__)), - 'resource-path') + resource_file = os.path.join(os.path.abspath(os.path.dirname( + conv_to_unicode(__file__))), 'resource-path') installed = os.path.exists(resource_file) if installed: test_path = os.path.join("gramps", "authors.xml") @@ -65,7 +65,7 @@ class ResourcePath(object): try: with io.open(resource_file, encoding='utf-8', errors='strict') as fp: - resource_path = fp.readline() + resource_path = conv_to_unicode(fp.readline()) except UnicodeError as err: LOG.exception("Encoding error while parsing resource path", err) sys.exit(1)