adding books from directory crashes with unicode error

Bug #1685819 reported by Valentin Roland on 2017-04-24
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

Adding books from a directory with multiple ebook files, calibre can crash when walking the directory.
Adding files via the add menu option produces a UnicodeDecodeError in line 133 of calibre/gui2/
os.walk() does not seems to work particularly well when the Unicode futures are involved. My quick workarround is to replace os.walk(root) with os.walk(str(root)), but this will probably cause problems in some cases, so someone with more knowledge about unicode strings in python2 should look over it.
Sorry for not including a traceback, but this problem should be easy to reproduce.

Calibre version: 2.83 on Arch Linux with python 2.7.13-

I cannot reproduce it. The only way that I know of for that to happen is
if you have files/directories in your filesystem whose names are not in
the character standard encoding as specified by your system
configuration (LANG env var, etc.).

Since calibre reads metadata from filenames, it requires them to be
decodable. I suppose, I could re-implement os.walk() to try and ignore
such un-decodable names.

Indeed, it is generally desirable to not have entries in your
filesystem that are not decodable. Allowing arbitrary binary data in
filenames is one of the more boneheaded things that Linux does. It is
alone amongst the major OSes to do that. Problems like this one are the
consequence of that. A bit of googling will show you how to find such
filenames in your filesystem and fix them.

Fixed in branch master. The fix will be in the next release. calibre is usually released every alternate Friday.

 status fixreleased

Changed in calibre:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers