Optional Parameters in python COM

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rane Bowen

    Optional Parameters in python COM

    Hi,

    I am using python with a makepy generated wrapper on a COM application. One
    of this object's methods has 3 parameters, two of which are optional.
    If I call the method with just the non-optional parameter, or all three
    parameters, it works. If I call it with the first two parameters, I get the
    following error:

    (-2147352567, 'Exception occurred.', (0, 'Amphora.Sessio n.1', 'A bad
    parameter was passed to the method', None, 0, -1610547133), None)

    I have tried calling the method by using the names of the optional
    parameters, and I have also tried using pythoncom.Missi ng and
    pythoncom.Empty for the non essential parameter. I have also edited the
    generated .py file so that it contains the following:

    defaultNamedOpt Arg=pythoncom.E mpty
    defaultNamedNot OptArg=pythonco m.Empty
    defaultUnnamedA rg=pythoncom.Em pty

    But this has not made any difference! Any help would be very much
    appreciated.

    Cheers,

    Rane


  • Rane Bowen

    #2
    Re: Optional Parameters in python COM

    <bump>

    "Rane Bowen" <raneb@slingsho t.co.nz> wrote in message
    news:bv1rek$oof $1@lust.ihug.co .nz...[color=blue]
    > Hi,
    >
    > I am using python with a makepy generated wrapper on a COM application.[/color]
    One[color=blue]
    > of this object's methods has 3 parameters, two of which are optional.
    > If I call the method with just the non-optional parameter, or all three
    > parameters, it works. If I call it with the first two parameters, I get[/color]
    the[color=blue]
    > following error:
    >
    > (-2147352567, 'Exception occurred.', (0, 'Amphora.Sessio n.1', 'A bad
    > parameter was passed to the method', None, 0, -1610547133), None)
    >
    > I have tried calling the method by using the names of the optional
    > parameters, and I have also tried using pythoncom.Missi ng and
    > pythoncom.Empty for the non essential parameter. I have also edited the
    > generated .py file so that it contains the following:
    >
    > defaultNamedOpt Arg=pythoncom.E mpty
    > defaultNamedNot OptArg=pythonco m.Empty
    > defaultUnnamedA rg=pythoncom.Em pty
    >
    > But this has not made any difference! Any help would be very much
    > appreciated.
    >
    > Cheers,
    >
    > Rane
    >
    >[/color]


    Comment

    • Rane Bowen

      #3
      Re: Optional Parameters in python COM

      <grind>
      "Rane Bowen" <raneb@slingsho t.co.nz> wrote in message
      news:bv3pos$2no $1@lust.ihug.co .nz...[color=blue]
      > <bump>
      >
      > "Rane Bowen" <raneb@slingsho t.co.nz> wrote in message
      > news:bv1rek$oof $1@lust.ihug.co .nz...[color=green]
      > > Hi,
      > >
      > > I am using python with a makepy generated wrapper on a COM application.[/color]
      > One[color=green]
      > > of this object's methods has 3 parameters, two of which are optional.
      > > If I call the method with just the non-optional parameter, or all three
      > > parameters, it works. If I call it with the first two parameters, I get[/color]
      > the[color=green]
      > > following error:
      > >
      > > (-2147352567, 'Exception occurred.', (0, 'Amphora.Sessio n.1', 'A bad
      > > parameter was passed to the method', None, 0, -1610547133), None)
      > >
      > > I have tried calling the method by using the names of the optional
      > > parameters, and I have also tried using pythoncom.Missi ng and
      > > pythoncom.Empty for the non essential parameter. I have also edited the
      > > generated .py file so that it contains the following:
      > >
      > > defaultNamedOpt Arg=pythoncom.E mpty
      > > defaultNamedNot OptArg=pythonco m.Empty
      > > defaultUnnamedA rg=pythoncom.Em pty
      > >
      > > But this has not made any difference! Any help would be very much
      > > appreciated.
      > >
      > > Cheers,
      > >
      > > Rane
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Mark Hammond

        #4
        Re: Optional Parameters in python COM

        Rane Bowen wrote:
        [color=blue]
        > Hi,
        >
        > I am using python with a makepy generated wrapper on a COM application. One
        > of this object's methods has 3 parameters, two of which are optional.
        > If I call the method with just the non-optional parameter, or all three
        > parameters, it works. If I call it with the first two parameters, I get the
        > following error:
        >
        > (-2147352567, 'Exception occurred.', (0, 'Amphora.Sessio n.1', 'A bad
        > parameter was passed to the method', None, 0, -1610547133), None)
        >
        > I have tried calling the method by using the names of the optional
        > parameters, and I have also tried using pythoncom.Missi ng and
        > pythoncom.Empty for the non essential parameter. I have also edited the
        > generated .py file so that it contains the following:
        >
        > defaultNamedOpt Arg=pythoncom.E mpty
        > defaultNamedNot OptArg=pythonco m.Empty
        > defaultUnnamedA rg=pythoncom.Em pty
        >
        > But this has not made any difference! Any help would be very much
        > appreciated.[/color]

        Can you reproduce this problem with a "common" object, such as IE,
        MSOffice, or a trivial VB object with sourcecode? The problem is that
        it is up to each object to implement optional params, so it is very hard
        to pinpoint bugs in win32com here.

        Mark.

        Comment

        Working...