[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] unable to retrieve python exception type objects (C api)
From:       Phil Thompson <phil () riverbankcomputing ! com>
Date:       2017-04-24 17:39:08
Message-ID: 5B182B1E-0855-4D80-BDA9-DC8BFFDCC98F () riverbankcomputing ! com
[Download RAW message or body]

On 21 Apr 2017, at 1:13 pm, Philip Scott <safetyfirstphil@gmail.com> wrote:
> 
> Hi Folks,
> 
> According to the documentation online:
> SIP generates a Python object for each exception defined with the %Exception \
> directive. 
> These objects are named with the fully qualified exception name (i.e. including any \
> enclosing scope) prefixed by sipException_. For example, the type object for enum \
> Except defined in class Klass issipException_Klass_Except. 
> The objects of all imported exceptions are available to handwritten code.
> 
> This worked for us well in 4.17. I am trying to upgrade to 4.19 and came across a \
> problem. In 4.19, for a SIP module called say, 'foo,' there is an #define in \
> sipAPIfoo.h of the form 
> #define sipException_my_exception sipExportedExceptions_foo[0]
> 
> However, the array sipExportedExceptions_foo is defined in 'sipfoocmodule.cpp' but \
> not declared in any header file. 
> I managed to work around this in one module by simply declaring it before my \
> handwritten C code: 
> extern PyObject *sipExportedExceptions_foo[3];
> 
> But unfortunately got completely stuck when I came a cross a SIP file that was \
> shared between a couple of different modules as the name of the module it was going \
> to be used in could not be known. The code looks a bit like this (I believe it was \
> also taken from the PyQt example documentation somewhere): 
> %Exception std::exception(SIP_Exception) /PyName=StdException/
> {
> %TypeHeaderCode
> #include <exception>
> %End
> %RaiseCode
> const char* what = sipExceptionRef.what();
> SIP_BLOCK_THREADS
> PyErr_SetString(sipException_std_exception, what);
> SIP_UNBLOCK_THREADS
> %End
> };
> 
> I wonder if this is related to the incompatibility notes from the 4.19 release:
> 
> Starting with this version only those type structures needed by the generated code \
> are automatically available to handwritten code possibly resulting in compiler \
> errors. Handwritten code should be changed to call sipFindType() to obtain a \
> pointer to the required type structure. 
> I did try using sipFindType to find my exception type but with no success, and \
> looking at the generated code I can't see anywhere that the exceptions are \
> registered in any way except in the python module dictionary. 
> Apologies if this question has been asked already - I did do a quick ctrl+f of the \
> post titles to the mailing list; I couldn't find a better way to search. I've been \
> googling for a solid day, I can't believe this hasn't affected anyone else - \
> perhaps our usage is non-standard in some way? 
> Anyhow, any pointers would be greatly appreciated.

Hmm, so little code, so many bugs...

Can you try tonight's snapshot?

Thanks,
Phil
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic