Python2.6 + win32com crashes with unicode bug

G

GerritM

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
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)
---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
---configuration data---
Windows XP SP3
ASUS 1106HA (11.6" EEE PC)
Visio 5.0
 
T

Terry Reedy

GerritM said:
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
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
---configuration data---
Windows XP SP3
ASUS 1106HA (11.6" EEE PC)
Visio 5.0
 
J

John Machin

GerritM wrote: [snip]
  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

Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more
information. Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0x83 in
position 0: ordinal not in range(128)
What bug??
 
G

GerritM

Terry Reedy schreef:
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: 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
 
G

GerritM

Terry Reedy schreef:
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: 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
 
S

Stefan Schukat

Hello Gerrit,

there is no problem in the file, but in the description of the Visio API. The place where the error occurs is during the definition
of the parameters of the corresponding Python methods. The information for the names comes from the typelibrary of visio. Probably there is a
non english name inside the typelibrary (MS used native names in early Office products) which then could not decoded to a correct Python name.
In my Version of Vsio OpenEx has two parameters called FileName and Flags. You have to look in your typelibrary, e.g. with OleView
http://www.microsoft.com/downloads/...0d-d9b2-4cb5-aeb6-45664be858b6&displaylang=en and check the parameters.


Regards

Stefan



-----Ursprüngliche Nachricht-----
Von: [email protected] [mailto:p[email protected]] Im Auftrag von GerritM
Gesendet: Freitag, 30. Oktober 2009 18:00
An: Terry Reedy
Cc: (e-mail address removed)
Betreff: Re: Python2.6 + win32com crashes with unicode bug


Terry Reedy schreef:
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: 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top