[PyQt] Segfault on exceptions in QNetworkAccessManager::createRequest
phil at riverbankcomputing.com
Thu Sep 25 16:57:14 BST 2014
On 25/09/2014 10:13 am, Florian Bruhin wrote:
> * Phil Thompson <phil at riverbankcomputing.com> [2014-09-22 18:03:54
>> On 16/09/2014 7:00 pm, Florian Bruhin wrote:
>> >I noticed I get a segfault when there's an exception in
>> >Is this a bug in PyQt? Or is it just a tricky situation maybe (wild
>> >guesses following) because the code there is running in another
>> >thread, and Qt expects to get a proper QNetworkRequest?
>> >An example script is attached.
>> I think it's just that Qt expects a QNetworkRequest and doesn't handle
>> NULL pointer.
> So PyQt returns NULL when an exception happens inside a Qt method, is
> that correct?
> I noticed when I returns an invalid return type (like False), I get
> PyQt's TypeError as an exception without any segfault. What happens on
> a C++ level there? Maybe other exceptions in there should be handled
> the same way?
The value returned depends on the C++ return type. In this case, where a
pointer is expected, the value is NULL.
The way to handle this might be to add a new annotation /NotNone/ that
says that NULL should not be returned to C++, or another annotation
might specify the default value that is returned when an exception is
raised. However in either case you won't be telling C++ that there is a
problem and it will carry on regardless - maybe a crash is the best
thing to do in this circumstance.
More information about the PyQt