Unicode error in exefied Python script
Martin v. Löwis
martin at v.loewis.de
Mon Jan 20 03:57:13 EST 2003
Tim Daneliuk <tundra at tundraware.com> writes:
> s += Name of a file
[...]
> I got the error you mentioned. After poking at it for a while, I
> discovered that the Win32 API was returning *Unicode* strings, but all
> my stuff was in ASCII. What was truly wierd about it is that the error
> didn't get thrown until the last s += statement, even though the error
> was introduced in the Win32Result statement. Python GURUS: Any idea why
> this is??????
Most likely, "Name of a file" was not an ASCII string, but a byte
string containing non-ASCII characters. As s was already a Unicode
object, that byte string was converted to Unicode, which failed.
You could also have solved this by writing
s += unicode(Name of file, encoding that your operating system uses
for file names)
Regards,
Martin
More information about the Python-list
mailing list