Re: odd unicode error



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.
.



Relevant Pages

  • Re: File names size limit?
    ... "The following are a few limitations of the NTFS file system. ... Reserved File Names ... Though the file system supports paths up to ca. 32,000 Unicode characters ...
    (microsoft.public.windows.file_system)
  • Re: Unicode entries on sys.path
    ... > What about removable drives? ... And mountable multiple file system types? ... in UCS-2LE (i.e. "Unicode proper"), through the vfat, ntfs, or joliet ... a proper patch to use wide APIs is incorporated in Python, ...
    (comp.lang.python)
  • Re: os.lisdir, gets unicode, returns unicode... USUALLY?!?!?
    ... you can have that conflict only if the file system encoding ... Unicode if they're actually stored that way in the underlying file ... Unicode strings returned from listdir, ...
    (comp.lang.python)
  • Re: the tostring and XML methods in ElementTree
    ... XML() method is the results of a tostringmethod from beforeRoot ... the argument be to the encode method? ... Dealing with unicode doesn't require you to pollute your code with ... unicode strings directly: ...
    (comp.lang.python)
  • Re: Python syntax in Lisp and Scheme
    ... say Unicode characters 27E8 and 27E9? ... What's unicode support like in general for Lisp? ... But do regexps work on unicode strings? ...
    (comp.lang.python)