[PyQt] SIP: newbie question 3

Johan Råde johan.rade at gmail.com
Fri Jul 8 09:55:46 BST 2011


On 2011-07-08 10:13, Sébastien Petitdemange wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi Johan,
>
> On 07/08/2011 09:58 AM, Johan Råde wrote:
>> I tried adding the following directive to my sip file, but it seems to
>> have no effect. There is still a crash when an exception is thrown in
>> the C++ code.
>>
>>
>> %Exception std::exception
>> {
>> %TypeHeaderCode
>> #    include "../../Common.h"
>> #    include "../../TextTable/Exceptions.h"
>> %End
>> %RaiseCode
>>      SIP_BLOCK_THREADS
>>      translate(sipExceptionRef)
>>      SIP_UNBLOCK_THREADS
>> %End
>> };
>
> Try this:
>
> %Exception std::exception(SIP_Exception) /Default/
> {
> %TypeHeaderCode
> #    include "../../Common.h"
> #    include "../../TextTable/Exceptions.h"
> %End
> %RaiseCode
>       SIP_BLOCK_THREADS
>       translate(sipExceptionRef)
>       SIP_UNBLOCK_THREADS
> %End
> };
>
> Seb
>



That does not work either. I also tried the code

%Exception std::exception(SIP_Exception) /PyName=StdException/
{
%TypeHeaderCode
#include <exception>
%End
%RaiseCode
     const char *detail = sipExceptionRef.what();
     SIP_BLOCK_THREADS
     PyErr_SetString(sipException_std_exception, detail);
     SIP_UNBLOCK_THREADS
%End
};

from the SIP reference guide. I still get a crash.
And I can not find any try/catch blocks in the generated cpp files.

My sip file begins as follows:

----------------------------------------------------------------------

%Module TextTable 0

%Include TypeMaps.sip

%Exception std::exception(SIP_Exception) /Default/
{
%TypeHeaderCode
#    include "../../Common.h"
#    include "../../TextTable/Exceptions.h"
%End
%RaiseCode
      SIP_BLOCK_THREADS
      translate(sipExceptionRef)
      SIP_UNBLOCK_THREADS
%End
};

class TextRow {

%TypeHeaderCode
#	include "../../Common.h"
#	include "../../TextTable/TextRow.h"
%End

public:
	TextRow(const TextRow& other);
	~TextRow();

...

---------------------------------------------------------------------------------






More information about the PyQt mailing list