[Chicago] UnicodeDecodeError When compiling BitTorrent in BitTornado

Ian Bicking ianb at colorstudy.com
Mon Oct 9 04:57:43 CEST 2006


>   12.   File "C:\Python24\lib\ntpath.py", line 102, in join
>   13.     path += "\\" + b
>   14. UnicodeDecodeError: 'ascii' codec can't decode byte 0xb9 in position 1: ordinal not in range(128)

This evaluates path + ("\\"+b)

That means that if b is unicode, ("\\"+b) will be a unicode string.  No
exception occurs, because "\\".decode('ascii') works fine.

Then when you add that to path, if path is not unicode then
path.decode('ascii') is called.  This is the exception you are getting.

So at some point a file or configuration value or something like that is
reading an encoded and non-ASCII string, and using that as "path".  Then
the unicode object "b" is being appended to that.  Or the other way
around might be true -- path is unicode and b is a non-ASCII encoded string.

I'm not really sure what the code should be, though I suppose ideally
sys.getfilesystemencoding() would be used to decode those strings
instead of ASCII.  This stuff can be a real mess.

-- 
Ian Bicking | ianb at colorstudy.com | http://blog.ianbicking.org


More information about the Chicago mailing list