These two things are not the same. In Gramps, your locale has been set, and str has been redefined so unicode is used. In python in terminal, these are all the ascii codec.

As you want to pass a path, you should probably pass the path in the encoding of the filesystem.
So something like

        fname = self._filename.encode(sys.getfilesystemencoding())
You should check if ROOT_DIR you use is already unicode. I know HOME_DIR in const is, so encode works, but for ROOT_DIR I see

 ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(
        unicode(__file__, sys.getfilesystemencoding())), os.pardir))

So, there is a unicode cast in there, which I assume will make it unicode in the end.

2012/9/12 Serge Noiraud <>

I have a strange problem and don't know if I am alone :

If I do :
$ python
 >>>import cairo
 >>>path = "/home/serge/trunk/src/images/48x48/gramps-geo-mainmap.png"
<cairo.ImageSurface object at 0x7fdbe2207af0>

so, it works.

In gramps in, I do :
self.geo_mainmap = cairo.ImageSurface.create_from_png(
             os.path.join(ROOT_DIR, "images", "48x48",
                          ('gramps-geo-mainmap' + '.png' )))
which is the same. I split the above instruction like the sample test in python
I always get a SIGSEGV !
with gdb, I obtain :
Program received signal SIGSEGV, Segmentation fault.
0x0000000000488461 in _PyCodec_Lookup ()
(gdb) backtrace
#0  0x0000000000488461 in _PyCodec_Lookup ()
#1  0x000000000048871d in ?? ()
#2  0x00000000004888da in PyCodec_Encode ()
#3  0x0000000000521ce1 in PyUnicodeUCS4_AsEncodedString ()
#4  0x0000000000523300 in _PyUnicodeUCS4_AsDefaultEncodedString ()
#5  0x00000000005116f3 in PyString_AsStringAndSize ()
#6  0x000000000044c7dd in ?? ()
#7  0x00007fffe6d7daf2 in ?? () from /usr/lib/python2.7/dist-packages/cairo/
#8  0x000000000045b0bd in PyEval_EvalFrameEx ()
#9  0x0000000000462269 in PyEval_EvalCodeEx ()
#10 0x00000000004aa37a in ?? ()
#11 0x000000000048273d in ?? ()
#12 0x000000000045afee in PyEval_EvalFrameEx ()
#13 0x0000000000462269 in PyEval_EvalCodeEx ()
#14 0x00000000004aa37a in ?? ()
#15 0x000000000048273d in ?? ()

has someone already seen that ?
It worked 2 or 3 days ago.
I done nothing except the ubuntu updates.

Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
Gramps-devel mailing list