[PyQt] Sip generates wrong argument parsing code

Olaf Schumann schumann at ph2.uni-koeln.de
Wed Jun 11 18:13:21 BST 2008


Hello, I have a problem with sip 4.7.6 under both linux and windows

I wrap a self-written C++-library for Python.
For a Matrix-Object I implement a __getitem__ and __setitem__ method in 
the sip-file with two integer arguments. While the __setitem__ function 
is working from python, the __get__item__ generates the following error:

argument 1 of Mat3D.__getitem__() has an invalid type


the corresponding code in the sip-file is:

[...]
  void __setitem__(int i, int j, double d);
%MethodCode
    Py_BEGIN_ALLOW_THREADS
    *(*sipCpp).at(a0,a1)=a2;
    Py_END_ALLOW_THREADS
%End

  double __getitem__(int i, int j);
%MethodCode
    Py_BEGIN_ALLOW_THREADS
    sipRes = *((*sipCpp).at(a0, a1));
    Py_END_ALLOW_THREADS
%End

[...]


The argument parsing in the __getitem__ function looks like:



        if (sipParseArgs(&sipArgsParsed,sipArg,"1ii",&a0,&a1))
        {
            double sipRes = 0;

Here, i would not expect the "1" before the "i"s? Is this my fault or a 
bug in sip?


The complete generated __getitem__ function is below, if necessary  I 
could send the complete source code (sip-files, cpp files etc).


sincerely,

    Olaf Schumann






extern "C" {static PyObject *slot_Mat3D___getitem__(PyObject 
*sipSelf,PyObject *sipArg);}
static PyObject *slot_Mat3D___getitem__(PyObject *sipSelf,PyObject *sipArg)
{
    Mat3D *sipCpp = reinterpret_cast<Mat3D *>(sipGetCppPtr((sipWrapper 
*)sipSelf,sipClass_Mat3D));

    if (!sipCpp)
        return 0;

    int sipArgsParsed = 0;

    {
        int a0;
        int a1;

        if (sipParseArgs(&sipArgsParsed,sipArg,"1ii",&a0,&a1))
        {
            double sipRes = 0;

#line 96 "ToolBoxMat3D.sip"
    Py_BEGIN_ALLOW_THREADS
    sipRes = *((*sipCpp).at(a0, a1));
    Py_END_ALLOW_THREADS
#line 202 "sipToolBoxMat3D.cpp"

            return PyFloat_FromDouble(sipRes);
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    
sipNoMethod(sipArgsParsed,sipNm_ToolBox_Mat3D,sipNm_ToolBox___getitem__);

    return 0;
}


-- 
Olaf Schumann
II. Physikalisches Institut
Universität zu Köln
Zülpicher Strasse 77, 50937 Köln
Tel.: +49-221-470-3591
Fax.: +49-221-470-6708
Skype: o_j_schumann





More information about the PyQt mailing list