[PyKDE] Re: PyKDE] SIP 4.0 problems

Phil Thompson phil at riverbankcomputing.co.uk
Sat Apr 10 20:23:00 BST 2004


On Friday 09 April 2004 1:47 am, Paul F. Kunz wrote:
>    In this script
>
> import sys
> from qt import *
> from sihippo import *
>
> app = QApplication ( sys.argv )
> ntc = NTupleController.instance()
> nt2 = ntc.createCircularBuffer(2)
> nt2.setLabels(['Time', 'TEM Current'])
> nt2.setTitle('GTIC Test2')
> time_list = range(100)
> amps = [0.0] * 100
> try :
>     nt2.addColumn('Time', time_list)
>     nt2.addColumn('TEM Current', amps)
> except DataSourceException, detail :
>     print detail.what()
>
> the nt2.addColumn() throws and exception in C++.   If SIPed with -e it
> works fine...
>
> [pfkeb at kunz-pbdsl1 sip]$ python cb_addcol.py
> NTuple::addColumn: column has wrong size
> [pfkeb at kunz-pbdsl1 sip]$
>
> But when SIPed with -e -g it yields ...
>
> pfkeb at kunz-pbdsl1 sip]$ python cb_addcol.py
> Segmentation fault (core dumped)
> [pfkeb at kunz-pbdsl1 sip]$
>
> It also worked fine with SIP 3.8 and later.   This is true both for
> Linux and Windows.
>
> The group using this code needs SIP 4.x and the -g option for other
> reasons.
>
>    What might be the cause of this problem.   The .sip file for
> DataSourceException.sip is enclosed.
>
> ---
>
> class DataSourceException
> {
> %TypeHeaderCode
> #include "datasrcs/DataSourceException.h"
> %End
>
>
> public:
>
>   DataSourceException ( const std::string & );
>   const char * what () const throw ();
>
>   char * __str__();
> %MethodCode
>     return PyString_FromString ( sipCpp->what() );
> %End
>
> };

There is a bug in SIP v4 (fixed in tonight's snapshot) that happens only if 
you specify both the -e and -g flags - but I'm not convinced it would affect 
the above. (Depends on what the rest of your module is doing I suppose.)

Note that the -g flag isn't tested and was only really there as an emergency 
fallback in case there were problems with the new GIL management code (which 
there aren't). You really shouldn't need to use it.

Phil




More information about the PyQt mailing list