odd unicode error

tubby tubby at bandaheart.com
Thu Apr 12 13:56:44 EDT 2007


This:

for root, dirs, files in os.walk(search_path):
     for f in files:
         print f

###############

Produces this:

Traceback (most recent call last):
   File "/home/brad/Desktop/my_script.pyw", line 340, in -toplevel-
     hunt(target_files(search_path, skip_file_extensions(), 
skip_files()), path_to_results)
   File "/home/brad/Desktop/my_script.pyw", line 161, in target_files
     for root, dirs, files in os.walk(search_path):
   File "os.py", line 291, in walk
     for x in walk(path, topdown, onerror):
   File "os.py", line 291, in walk
     for x in walk(path, topdown, onerror):
   File "os.py", line 281, in walk
     if isdir(join(top, name)):
   File "posixpath.py", line 65, in join
     path += '/' + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 1: 
ordinal not in range(128)

##################

I'm running Python 2.4.4c1 (#2, Oct 11 2006, 21:51:02)
[GCC 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)] on linux2

Any ideas? I can't catch this with try/except and using unicode(f) 
doesn't help either.



More information about the Python-list mailing list