[cairo] PyCairo crashes
Michael Droettboom
mdroe at stsci.edu
Tue Nov 17 10:11:19 PST 2009
Steve wrote:
> On Tue, 2009-11-17 at 03:12 -0800, cairo-request at cairographics.org
> wrote:
>
>> On Mon, 16 Nov 2009 16:49:42 +0100, Simon B?chler <sbaechler at me.com>
>> wrote:
>>
>>> self.basename=self.basename.decode("unicode_escape","ignore")
>>> self.basename=self.basename.encode("ascii","ignore")
>>>
>>> self.surface2.write_to_png(self.basename)
>>>
>>> Now special characters are just left out which is sad. Apparently
>>>
>> the
>>
>>> function cannot deal with those.
>>>
If you have a Unicode path, and are sending it to a function that takes
only strings, you generally want to do:
path.encode(sys.getfilesystemencoding())
which do the right thing to encode the path into something the low-level
C "fopen" can understand.
One could argue it might be more "Pythonic" for PyCairo to handle that
conversion internally, but hopefully the above is the correct workaround.
Mike
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
More information about the cairo
mailing list