Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upBeets crashing with UnicodeError on initial import #2585
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
sampsyo
Jun 5, 2017
Member
Hmm; thanks for filing! It sounds like this is an issue with handling the encoding of the top-level path you were trying to import (i.e., a path you specified on the command line). Could that be right? Were there non-ASCII characters in that path?
[Technical details warning.] If so, I think the problem is that, on Python 3, the import command handler (beets.ui.commands.import_func) gets the paths list from the command-line arguments, so they're Unicode strings. (On Python 2, they're bytes.) We need to get these into bytes form. This was hidden from most people, but your system seems to not be specifying its filesystem encoding, and the path was non-UTF-8. This was bound to happen eventually. The right solution is to convert these paths back to bytes in import_func, before handing them off to import_files.
Edit: To revise that prediction a bit, I think the problem is not that your OS isn't reporting an encoding; it's just that the file path doesn't fit in that encoding—which isn't all that rare. Our exception handler in bytestring_path is getting triggered. We need something like path.encode(_fsencoding(), 'surrogateescape').
To confirm, can you also please try running this command to see what Python thinks your filesystem encoding is?
$ python3 -c 'import sys; print(sys.getfilesystemencoding())'
|
Hmm; thanks for filing! It sounds like this is an issue with handling the encoding of the top-level path you were trying to import (i.e., a path you specified on the command line). Could that be right? Were there non-ASCII characters in that path? [Technical details warning.] If so, I think the problem is that, on Python 3, the Edit: To revise that prediction a bit, I think the problem is not that your OS isn't reporting an encoding; it's just that the file path doesn't fit in that encoding—which isn't all that rare. Our exception handler in To confirm, can you also please try running this command to see what Python thinks your filesystem encoding is?
|
sampsyo
added
the
needinfo
label
Jun 5, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
prg318
Jun 5, 2017
Hi! The toplevel path I was importing was actually plain ASCII (/media/nas/audio). I'm somewhat upset that I am unable to reproduce this bug! To get more debugging information, I ran my initial import with "-vv" ("beets -vv import -A /media/nas/audio") and it worked! Furthermore, I have cleared my database again and am now reimporting again without the "-vv" flags, and this is also working!
Maybe there was a transient issue going on somewhere in my system? My audio is mounted via NFS so there could been something funky going on with the NFS server at the time perhaps? Maybe I launched my beets import from a really funky terminal where the locale was screwed up (very unlikely but possible!)
Until this issue is reproducable, I'd say maybe we can close it until someone can reproduce it again?
Thanks for your feedback and looking into it - I will report back and re-open if I run into something like this again in the future. Sorry I don't have any debugging information to provide!
prg318
commented
Jun 5, 2017
|
Hi! The toplevel path I was importing was actually plain ASCII (/media/nas/audio). I'm somewhat upset that I am unable to reproduce this bug! To get more debugging information, I ran my initial import with "-vv" ("beets -vv import -A /media/nas/audio") and it worked! Furthermore, I have cleared my database again and am now reimporting again without the "-vv" flags, and this is also working! Maybe there was a transient issue going on somewhere in my system? My audio is mounted via NFS so there could been something funky going on with the NFS server at the time perhaps? Maybe I launched my beets import from a really funky terminal where the locale was screwed up (very unlikely but possible!) Until this issue is reproducable, I'd say maybe we can close it until someone can reproduce it again? Thanks for your feedback and looking into it - I will report back and re-open if I run into something like this again in the future. Sorry I don't have any debugging information to provide! |
prg318
closed this
Jun 5, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
sampsyo
Jun 6, 2017
Member
That certainly is very strange! I still think the fix I outlined above is probably the right one, but let's chalk it up to a flaky NAS connection for now and see if this reappears.
|
That certainly is very strange! I still think the fix I outlined above is probably the right one, but let's chalk it up to a flaky NAS connection for now and see if this reappears. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
itheof
Jan 16, 2018
Hi! I just had the same issue with a folder containing é' characters. Changing it to a regulare' made it work. Please tell me if there is any information I could provide to help narrowing the real issue
itheof
commented
Jan 16, 2018
|
Hi! I just had the same issue with a folder containing |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
sampsyo
Jan 16, 2018
Member
Hmm; that's troubling, @itheof! If it's something you can reproduce reliably, please open another bug.
|
Hmm; that's troubling, @itheof! If it's something you can reproduce reliably, please open another bug. |
prg318 commentedJun 5, 2017
Problem
I was running an initial import (no autotag, "-A") of a large mp3 library and got the following error:
I am running on a unicode system which I believe is configured properly:
Setup
My configuration (output of
beet config) is: