Python2.6 + win32com crashes with unicode bug

GerritM gerrit.muller at gmail.com
Fri Oct 30 13:00:29 EDT 2009


Terry Reedy schreef:
> GerritM wrote:
>> I have automated image generation with Python, win32com and Visio5.0. 
>> This works well upto Python2.5 but fails with Python 2.6.
>> Short term solution is to return to 2.5 :-(.
>>
>> I have reproduced the bug below with a minimum of Python lines. Below 
>> the problem the working example from 2.5
>>
>> kind regards, Gerrit
>>
>> ---minimal session reproducing the bug---
>>
<..snip..>
>> d = v.Documents.OpenEx("D:/temp/test.vsd",8)
<...snip...>
>> UnicodeDecodeError: 'ascii' codec can't decode byte 0x83 in position 
>> 52: ordinal not in range(128)
> 
> I suspect that 2.6 fixed the bug of allowing non-ascii chars when using 
> the ascii codec.  I would check to see if there is an 0x83 in 
> D:/temp/test.vsd
> 
<...snip...>
the string "D:/temp/test.vsd" itself does not contain any 
charactervalue>128:
 >>> for c in "D:/temp/test.vsd":
	print ord(c), " ",

68   58   47   116   101   109   112   47   116   101   115   116   46 
  118   115   100
(on my current Python 2.5 configuration)

The presumably binary file itself may contain any value, but I don't 
expect Python or win32com to do anything with the file content...

There are explanations on internet that Windows uses internally 2 
(incompatible) API's that cause poblems with Unicode based filenames. I 
do something like that to be the problem in Python 2.6

kind regards, Gerrit




More information about the Python-list mailing list