[PyQt] Re: New bug in SIP

Phil Thompson phil at riverbankcomputing.co.uk
Fri May 30 11:32:28 BST 2008


On Wednesday 28 May 2008 3:39:11 pm Giovanni Bajo wrote:
> Hi Phil,
>
> I found a new bug in SIP (it used to work with a SIP from September 2007).
>
> If you declare a class with a single constructor, you write %MethodCode
> for that constructor, and you make it raise an exception (PyErr_Format)
> and set sipIsErr=1, the exception is not propagated to Python: it gets
> "swallowed" and changed into an AttributeError which says "... is a
> private method".
>
> Basically, this code in sipWrapper_init, line 7173:
>
>              	/*
>              	 * If the arguments were parsed without error then assume an
>              	 * exception has already been raised for why the instance
>              	 * wasn't created.
>              	 */
>                  if (pstate == PARSE_OK)
>                      argsparsed = PARSE_RAISED;
>
>
> is not executed, because pstate was already mutated a few lines above:
>
>
>              /*
>               * If the parse was successful but no C/C++ object was
> created then
>               * we assume that handwritten code decided after the parse
> that * it didn't want to handle the signature.
>               */
>              if (pstate == PARSE_OK)
>                  pstate = PARSE_TYPE;
>
>
> I was wondering if it should check "argsparsed == PARSE_OK" (at line
> 7173) instead of "pstate == PARSE_OK".
>
> Thanks!

I think the bug is that the earlier code should be...

    if (pstate == PARSE_OK)
        pstate = argsparsed = PARSE_TYPE;

Phil


More information about the PyQt mailing list