odd unicode error

tubby tubby at bandaheart.com
Thu Apr 12 14:54:53 EDT 2007


Martin v. Löwis wrote:
>>     path += '/' + b
>> UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 1:
>> ordinal not in range(128)
>>
>> Any ideas?
> 
> path is a Unicode string, b is a byte string and contains the
> byte \xd0.
> 
> The problem is that you have a directory with file names in it that
> cannot be converted to Unicode strings, using the file system
> encoding. If you can't fix the file system, you have to make
> search_path a byte string.
> 
> Regards,
> Martin

I fixed it... I didn't tell the whole story. The interface uses 
wxpython. It returns a unicode pathname that os.walk() uses. I changed 
that pathname with str() and now, it no longer barfs.



More information about the Python-list mailing list