UnicodeDecodeError when opening a file with unicode characters in the path

Bug #802176 reported by János Illés
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
pyexiv2
Fix Released
High
Olivier Tilloy

Bug Description

pyexiv2 throws UnicodeDecodeError when using it on files with unicode charachters

      File "/usr/lib/python2.7/site-packages/pyexiv2/metadata.py", line 64, in __init__
        self.filename = filename.encode(sys.getfilesystemencoding())
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 31: ordinal not in range(128)

Converting the filename to unicode first will fix the issue:

    self.filename = unicode(filename,sys.getfilesystemencoding()).encode(sys.getfilesystemencoding())

I'm using pyexiv2 0.3.0, compiled against 0.21.1 libexiv2

Revision history for this message
Olivier Tilloy (osomon) wrote :

Thanks for the report János, and sorry for the delay in answering.

In order for me to reproduce and fix the issue, could you please provide me the following information?

 • output of the following command: python -c "import sys; print sys.getfilesystemencoding(); print sys.getdefaultencoding()"
 • name of the file that triggers the bug
 • output of the following command: python -c "import os; print os.listdir('DIRECTORY')"
   (replace DIRECTORY with the full path to the parent directory that contains the file that triggers the bug)

Thanks in advance!

Changed in pyexiv2:
status: New → Incomplete
Revision history for this message
János Illés (ijanos) wrote :

Hi,

$ python -c "import sys; print sys.getfilesystemencoding(); print sys.getdefaultencoding()"
UTF-8
ascii

The filename is standard like IMG0001.jpg, the problem is in with the image path: ~/Fotók/IMG0001.jpg

The listdir is irrelevant. I can trigger the bug with a singe image if the path or the filename contains non-ascii UTF-8 characters.

ps: sorry for the delay, looks like the spamfilter ate the notification email.

Revision history for this message
Olivier Tilloy (osomon) wrote :

Thanks for the feedback János. I can reproduce the issue, I'll investigate it.

Changed in pyexiv2:
assignee: nobody → Olivier Tilloy (osomon)
importance: Undecided → High
status: Incomplete → Confirmed
Olivier Tilloy (osomon)
Changed in pyexiv2:
status: Confirmed → In Progress
Revision history for this message
Olivier Tilloy (osomon) wrote :

Fixed with revision 358 in the trunk.

Changed in pyexiv2:
status: In Progress → Fix Committed
Revision history for this message
Markus Golser (golserma) wrote :

Just had this issues maybe a point release is a nice idea?

Revision history for this message
Olivier Tilloy (osomon) wrote :

Markus: yes, a point release is on my to-do list, it has been delayed but I hope to be able to get to it soon.

Olivier Tilloy (osomon)
Changed in pyexiv2:
milestone: none → 0.3.1
Olivier Tilloy (osomon)
Changed in pyexiv2:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.