Unicode error in exefied Python script

Tim Daneliuk tundra at tundraware.com
Mon Jan 20 17:30:06 EST 2003


Martin v. Löwis wrote:
> Tim Daneliuk <tundra at tundraware.com> writes:
> 
> 
>>Exactly right - So when concatenating strings like I did above,
>>Python always promotes the result to the 'higher' type?
> 
> 
> Where 'higher' type means the two of the types which is the superset
> of the other, in some sense - yes. It is, however, questionable which
> of the types is supertype, here, since there are byte strings which
> cannot be converted to Unicode, and Unicode strings which cannot be
> converted to byte strings.
> 
> So for this situation, a special exception from this "always" rule is
> made: byte strings are promoted to Unicode strings when the two are
> combined.

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

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





More information about the Python-list mailing list