Closed rfilmyer closed 9 years ago
I notice that @codyzu changed this line when adding in some 2/3 compatibility. Will the original line (the one commented out up top) not work with python 3?
Looking at this again. 0xCC
is just ASCII, but 0xCC 0x81
refers to an acute accent - ´
.
The Library initialization failed on this URL: file://localhost/Users/roger/Music/Albums/Boubacar%20Traore%CC%81%20-%20Mali%20Denhou/11%20Mali%20Tchebaou.mp3
(This should look like this when decoded properly: file://localhost/Users/roger/Music/Albums/Boubacar Traoré - Mali Denhou/11 Mali Tchebaou.mp3)
So this means that I need to find how to get Python 2's urllib.unquote()
to work with unicode strings.
Annoyingly, Python 2's urllib.unquote()
encodes the above link as '/Users/roger/Music/Albums/Boubacar Traore\xcc\x81 - Mali Denhou/11 Mali Tchebaou.mp3'
, which then needs to be decoded into proper unicode format - u'/Users/roger/Music/Albums/Boubacar Traore\u0301 - Mali Denhou/11 Mali Tchebaou.mp3'
, but six.u()
fails to do that. I'm having trouble finding an easy solution that would work with Python 2 and 3 combined.
text_type
does not work for decoding these strings, because it goes byte by byte (´
is 2 bytes long, so you get the UnicodeDecodeError).
(Ignore all the commits except for 7991560; it took a few tries to rebase my fork's branch to liamks's HEAD so my two pull requests could be created separately)
This should be fixed now in pull request #21.
Just got this using 2.7, conda environment w/ tensorflow. My library definitely has a lot of accents
---------------------------------------------------------------------------
UnicodeEncodeError Traceback (most recent call last)
<ipython-input-2-df9cbca52326> in <module>()
19 if song and song.rating:
20 if song.rating > 80:
---> 21 print("{n}, {r}".format(n=song.name, r=song.rating))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf1' in position 5: ordinal not in range(128)
I'm simply running the code for using pickle.
While I'm working on fixing my first issue, I ran into a problem with the most recent build of the library.
Loading my library, I ran into this error:
0xcc
corresponds to Ì, a "Latin capital letter I with grave". What's weird about this error is that this character doesn't appear at all in my library:The relevant line of code is here:
Commenting out the first s.location line allows me to load the library.