On 5/30/2008 3:30 PM, Phil Thompson wrote:
On Friday 30 May 2008 1:05:11 pm Giovanni Bajo wrote:
On 5/30/2008 12:32 PM, Phil Thompson wrote:
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;
This changes the exception into a TypeError (eg: "argument 1 has an
invalid type"), but it still mask the original exception that was raised
in the %MethodCode.

Hmm - I need to think about this a bit more. It's all related to the QVariant support for Python objects.

IMHO sip is getting to a complexity point where a testsuite might help in sorting out these bugs while you are developing new code and/or refactoring. If you are interested in having one, I can help contributing the infrastructure for it.
--
Giovanni Bajo
Develer S.r.l.
http://www.develer.com
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to