Python2.6 + win32com crashes with unicode bug

Discussion in 'Python' started by GerritM, Oct 29, 2009.

  1. GerritM

    GerritM Guest

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


    ---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
    GerritM, Oct 29, 2009
    #1
    1. Advertising

  2. GerritM

    Terry Reedy Guest

    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
    Terry Reedy, Oct 30, 2009
    #2
    1. Advertising

  3. GerritM

    John Machin Guest

    On Oct 30, 11:11 am, Terry Reedy <> wrote:
    > 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.
    >>> '\x83'.decode('ascii')

    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??
    John Machin, Oct 30, 2009
    #3
  4. GerritM

    GerritM Guest

    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
    GerritM, Oct 30, 2009
    #4
  5. GerritM

    GerritM Guest

    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
    GerritM, Oct 30, 2009
    #5
  6. AW: Python2.6 + win32com crashes with unicode bug

    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: python-list-bounces+sschukat= [mailto:python-list-bounces+sschukat=] Im Auftrag von GerritM
    Gesendet: Freitag, 30. Oktober 2009 18:00
    An: Terry Reedy
    Cc:
    Betreff: Re: Python2.6 + win32com crashes with unicode bug


    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

    --
    http://mail.python.org/mailman/listinfo/python-list
    Stefan Schukat, Nov 2, 2009
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Xavier
    Replies:
    0
    Views:
    405
    Xavier
    Aug 6, 2003
  2. Skip Montanaro
    Replies:
    1
    Views:
    418
    Thomas Heller
    Aug 7, 2003
  3. snacktime
    Replies:
    13
    Views:
    553
    Dan Sommers
    Feb 22, 2005
  4. Tim N. van der Leeuw

    win32com and Python2.4: Interpreter crashing!

    Tim N. van der Leeuw, Mar 7, 2005, in forum: Python
    Replies:
    1
    Views:
    289
    Roger Upole
    Mar 7, 2005
  5. Uwe Mayer

    changing from python2.3 to python2.4

    Uwe Mayer, Apr 8, 2005, in forum: Python
    Replies:
    1
    Views:
    290
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
    Apr 9, 2005
Loading...

Share This Page