7258: Ensure that resource paths are set correctly when they include Unicode characters.

This commit is contained in:
John Ralls 2014-04-20 13:48:59 -07:00
parent 8e164e29a2
commit efa3741579

View File

@ -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)