Unicode error in exefied Python script
Martin v. Löwis
martin at v.loewis.de
Tue Jan 21 03:16:07 EST 2003
Tim Daneliuk <tundra at tundraware.com> writes:
> Hmmm, I don't understand this last bit at all. If this is how it works,
> then why did my original example fail? Win32 returned a Unicode string
> which I concatenated w/ an ASCII string to produce a .. Unicode string.
> Later, when I tried to concatenate a byte string to that new Unicode string,
> the program failed - i.e., the byte string does not appear to get promoted...
Please understand that only some of the byte strings are ASCII
strings, namely those for which all bytes have ordinals < 128.
Python tries to convert the byte string to a Unicode string, using the
system default encoding (as returned from
sys.getdefaultencoding()). The factory setting for this is
'ascii'. When you have a byte string that contains non-ASCII
characters, conversion to Unicode fails, hence the error.
HTH,
Martin
More information about the Python-list
mailing list