Python2.6 + win32com crashes with unicode bug

Terry Reedy tjreedy at udel.edu
Fri Oct 30 01:11:14 CET 2009


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---
> 
> Python 2.6.3 (r263:75183, Oct  5 2009, 14:41:55) [MSC v.1500 32 bit 
> (Intel)] on win32
> Type "copyright", "credits" or "license()" for more information.
> 
>     ****************************************************************
>     Personal firewall software may warn about the connection IDLE
>     makes to its subprocess using this computer's internal loopback
>     interface.  This connection is not visible on any external
>     interface and no data is sent to or received from the Internet.
>     ****************************************************************
> 
> IDLE 2.6.3
>  >>> from win32com.client.dynamic import Dispatch
>  >>> v = Dispatch("Visio.Application")
>  >>> d = v.Documents.OpenEx("D:/temp/test.vsd",8)
> 
> Traceback (most recent call last):
>   File "<pyshell#2>", line 1, in <module>
>     d = v.Documents.OpenEx("D:/temp/test.vsd",8)
>   File "C:\Python26\lib\site-packages\win32com\client\dynamic.py", line 
> 467, in __getattr__
>     if self._olerepr_.mapFuncs.has_key(attr): return 
> self._make_method_(attr)
>   File "C:\Python26\lib\site-packages\win32com\client\dynamic.py", line 
> 295, in _make_method_
>     methodCodeList = 
> self._olerepr_.MakeFuncMethod(self._olerepr_.mapFuncs[name], methodName,0)
>   File "C:\Python26\lib\site-packages\win32com\client\build.py", line 
> 297, in MakeFuncMethod
>     return self.MakeDispatchFuncMethod(entry, name, bMakeClass)
>   File "C:\Python26\lib\site-packages\win32com\client\build.py", line 
> 318, in MakeDispatchFuncMethod
>     s = linePrefix + 'def ' + name + '(self' + BuildCallList(fdesc, 
> names, defNamedOptArg, defNamedNotOptArg, defUnnamedArg, defOutArg) + '):'
>   File "C:\Python26\lib\site-packages\win32com\client\build.py", line 
> 604, in BuildCallList
>     argName = MakePublicAttributeName(argName)
>   File "C:\Python26\lib\site-packages\win32com\client\build.py", line 
> 542, in MakePublicAttributeName
>     return filter( lambda char: char in valid_identifier_chars, className)
>   File "C:\Python26\lib\site-packages\win32com\client\build.py", line 
> 542, in <lambda>
>     return filter( lambda char: char in valid_identifier_chars, className)
> 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


> ---no problem with 2.5---
> Python 2.5 (r25:51908, Mar  9 2007, 17:40:28) [MSC v.1310 32 bit 
> (Intel)] on win32
> Type "copyright", "credits" or "license()" for more information.
> 
>     ****************************************************************
>     Personal firewall software may warn about the connection IDLE
>     makes to its subprocess using this computer's internal loopback
>     interface.  This connection is not visible on any external
>     interface and no data is sent to or received from the Internet.
>     ****************************************************************
> 
> IDLE 1.2
>  >>> from win32com.client.dynamic import Dispatch
>  >>> v = Dispatch("Visio.Application")
>  >>> d = v.Documents.OpenEx("D:/temp/test.vsd",8)
>  >>>
> 
> ---configuration data---
> Windows XP SP3
> ASUS 1106HA (11.6" EEE PC)
> Visio 5.0




More information about the Python-list mailing list