Unicode error in exefied Python script

Tim Daneliuk tundra at tundraware.com
Tue Jan 21 11:20:07 EST 2003


Martin v. Löwis wrote:
> 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
> 

Very clear.  Thanks very much for taking the time to answer my dumb
questions.

-- 
------------------------------------------------------------------------------
Tim Daneliuk
tundra at tundraware.com





More information about the Python-list mailing list