How to work around a unicode problem?

tinnews at isbd.co.uk tinnews at isbd.co.uk
Tue Jan 24 06:57:04 EST 2012


I have a small python program that uses the pyexiv2 package to view
exif data in image files.

I've hit a problem because I have a filename with accented characters
in its path and the pyexiv2 code traps as follows:-

    Traceback (most recent call last):
      File "/home/chris/bin/eview.py", line 87, in <module>
        image = pyexiv2.ImageMetadata(filepath)
      File "/usr/lib/python2.7/dist-packages/pyexiv2/metadata.py", line 65, in __init__
        self.filename = filename.encode(sys.getfilesystemencoding())
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 38: ordinal not in range(128)

Without digging deep into pyexiv2 is there any way I can work around
this error?  The accented characters aren't in the filename itself,
they're in the directory path.  I.e. it's:-

    ./1977/04 April/#09 - Monaco, inc. Musée de Poupée/p77_08_011.jpg

I could of course remove the accents but I'd much prefer not to do so.

-- 
Chris Green



More information about the Python-list mailing list