python3 requires str (=unicode) to load from file

svn: r20667
This commit is contained in:
Benny Malengier 2012-11-17 11:05:06 +00:00
parent 945819631c
commit 4e8437bae4
2 changed files with 10 additions and 4 deletions

View File

@ -150,11 +150,15 @@ class GeoGraphyView(OsmGps, NavigationView):
self.geo_mainmap = None
path = os.path.join(ROOT_DIR, "images", "48x48",
('gramps-geo-mainmap' + '.png' ))
pathu = path.encode(sys.getfilesystemencoding())
pathu = path
if sys.version_info[0] < 3:
pathu = path.encode(sys.getfilesystemencoding())
self.geo_mainmap = cairo.ImageSurface.create_from_png(pathu)
path = os.path.join(ROOT_DIR, "images", "48x48",
('gramps-geo-altmap' + '.png' ))
pathu = path.encode(sys.getfilesystemencoding())
pathu = path
if sys.version_info[0] < 3:
pathu = path.encode(sys.getfilesystemencoding())
self.geo_altmap = cairo.ImageSurface.create_from_png(pathu)
if ( config.get('geography.map_service') in
( constants.OPENSTREETMAP,
@ -169,7 +173,9 @@ class GeoGraphyView(OsmGps, NavigationView):
EventType.MARRIAGE ):
path = os.path.join(ROOT_DIR, "images", "48x48",
(constants.ICONS.get(int(ident), default_image) + '.png' ))
pathu = path.encode(sys.getfilesystemencoding())
pathu = path
if sys.version_info[0] < 3:
pathu = path.encode(sys.getfilesystemencoding())
self.geo_othermap[ident] = cairo.ImageSurface.create_from_png(pathu)
def change_page(self):

View File

@ -208,7 +208,7 @@ class PersonBoxWidgetCairo(_PersonWidgetBase):
self.img_surf = None
if image:
image_path = self.get_image(dbstate, person)
if isinstance(image_path, STRTYPE):
if sys.version_info[0] < 3 and isinstance(image_path, STRTYPE):
image_path = image_path.encode(sys.getfilesystemencoding())
if image_path and os.path.exists(image_path):
self.img_surf = cairo.ImageSurface.create_from_png(image_path)